llama-index-readers-reddit


Namellama-index-readers-reddit JSON
Version 0.1.2 PyPI version JSON
download
home_page
Summaryllama-index readers reddit integration
upload_time2024-02-13 21:42:07
maintainervanessahlyan
docs_urlNone
authorYour Name
requires_python>=3.8.1,<3.12
licenseMIT
keywords comments reddit search subreddit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Reddit Reader

For any subreddit(s) you're interested in, search for relevant posts using keyword(s) and load the resulting text in the post and and top-level comments into LLMs/ LangChains.

## Get your Reddit credentials ready

1. Visit Reddit App Preferences (https://www.reddit.com/prefs/apps) or [https://old.reddit.com/prefs/apps/](https://old.reddit.com/prefs/apps/)
2. Scroll to the bottom and click "create another app..."
3. Fill out the name, description, and redirect url for your app, then click "create app"
4. Now you should be able to see the personal use script, secret, and name of your app. Store those as environment variables REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, and REDDIT_USER_AGENT respecitvely.
5. Additionally store the environment variables REDDIT_USERNAME and REDDIT_PASSWORD, which correspond to the credentials for your Reddit account.

## Usage

### LlamaIndex

```python
from llama_index import VectorStoreIndex, download_loader

RedditReader = download_loader("RedditReader")

subreddits = ["MachineLearning"]
search_keys = ["PyTorch", "deploy"]
post_limit = 10

loader = RedditReader()
documents = loader.load_data(
    subreddits=subreddits, search_keys=search_keys, post_limit=post_limit
)
index = VectorStoreIndex.from_documents(documents)

index.query("What are the pain points of PyTorch users?")
```

### LangChain

```python
from llama_index import VectorStoreIndex, download_loader

from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI
from langchain.chains.conversation.memory import ConversationBufferMemory

RedditReader = download_loader("RedditReader")

subreddits = ["MachineLearning"]
search_keys = ["PyTorch", "deploy"]
post_limit = 10

loader = RedditReader()
documents = loader.load_data(
    subreddits=subreddits, search_keys=search_keys, post_limit=post_limit
)
index = VectorStoreIndex.from_documents(documents)

tools = [
    Tool(
        name="Reddit Index",
        func=lambda q: index.query(q),
        description=f"Useful when you want to read relevant posts and top-level comments in subreddits.",
    ),
]
llm = OpenAI(temperature=0)
memory = ConversationBufferMemory(memory_key="chat_history")
agent_chain = initialize_agent(
    tools, llm, agent="zero-shot-react-description", memory=memory
)

output = agent_chain.run(input="What are the pain points of PyTorch users?")
print(output)
```

This loader is designed to be used as a way to load data into [GPT Index](https://github.com/run-llama/llama_index/tree/main/llama_index) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent. See [here](https://github.com/emptycrown/llama-hub/tree/main) for examples.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "llama-index-readers-reddit",
    "maintainer": "vanessahlyan",
    "docs_url": null,
    "requires_python": ">=3.8.1,<3.12",
    "maintainer_email": "",
    "keywords": "comments,reddit,search,subreddit",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/94/da2a4d2852fb5b88372bb56920175614f004db1ccabe9712a730d45da5b2/llama_index_readers_reddit-0.1.2.tar.gz",
    "platform": null,
    "description": "# Reddit Reader\n\nFor any subreddit(s) you're interested in, search for relevant posts using keyword(s) and load the resulting text in the post and and top-level comments into LLMs/ LangChains.\n\n## Get your Reddit credentials ready\n\n1. Visit Reddit App Preferences (https://www.reddit.com/prefs/apps) or [https://old.reddit.com/prefs/apps/](https://old.reddit.com/prefs/apps/)\n2. Scroll to the bottom and click \"create another app...\"\n3. Fill out the name, description, and redirect url for your app, then click \"create app\"\n4. Now you should be able to see the personal use script, secret, and name of your app. Store those as environment variables REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, and REDDIT_USER_AGENT respecitvely.\n5. Additionally store the environment variables REDDIT_USERNAME and REDDIT_PASSWORD, which correspond to the credentials for your Reddit account.\n\n## Usage\n\n### LlamaIndex\n\n```python\nfrom llama_index import VectorStoreIndex, download_loader\n\nRedditReader = download_loader(\"RedditReader\")\n\nsubreddits = [\"MachineLearning\"]\nsearch_keys = [\"PyTorch\", \"deploy\"]\npost_limit = 10\n\nloader = RedditReader()\ndocuments = loader.load_data(\n    subreddits=subreddits, search_keys=search_keys, post_limit=post_limit\n)\nindex = VectorStoreIndex.from_documents(documents)\n\nindex.query(\"What are the pain points of PyTorch users?\")\n```\n\n### LangChain\n\n```python\nfrom llama_index import VectorStoreIndex, download_loader\n\nfrom langchain.agents import initialize_agent, Tool\nfrom langchain.llms import OpenAI\nfrom langchain.chains.conversation.memory import ConversationBufferMemory\n\nRedditReader = download_loader(\"RedditReader\")\n\nsubreddits = [\"MachineLearning\"]\nsearch_keys = [\"PyTorch\", \"deploy\"]\npost_limit = 10\n\nloader = RedditReader()\ndocuments = loader.load_data(\n    subreddits=subreddits, search_keys=search_keys, post_limit=post_limit\n)\nindex = VectorStoreIndex.from_documents(documents)\n\ntools = [\n    Tool(\n        name=\"Reddit Index\",\n        func=lambda q: index.query(q),\n        description=f\"Useful when you want to read relevant posts and top-level comments in subreddits.\",\n    ),\n]\nllm = OpenAI(temperature=0)\nmemory = ConversationBufferMemory(memory_key=\"chat_history\")\nagent_chain = initialize_agent(\n    tools, llm, agent=\"zero-shot-react-description\", memory=memory\n)\n\noutput = agent_chain.run(input=\"What are the pain points of PyTorch users?\")\nprint(output)\n```\n\nThis loader is designed to be used as a way to load data into [GPT Index](https://github.com/run-llama/llama_index/tree/main/llama_index) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent. See [here](https://github.com/emptycrown/llama-hub/tree/main) for examples.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index readers reddit integration",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [
        "comments",
        "reddit",
        "search",
        "subreddit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28ea79c58ccf5669fd5678534eaef6f355fca7b02c87e1a8460221bc1e302172",
                "md5": "e8a4a15199de92fd2e17fbee259ebda4",
                "sha256": "6336bab01fc8b642b4b3e737ab915c7f27105615517b6fa30322a394b6106692"
            },
            "downloads": -1,
            "filename": "llama_index_readers_reddit-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8a4a15199de92fd2e17fbee259ebda4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<3.12",
            "size": 3622,
            "upload_time": "2024-02-13T21:42:05",
            "upload_time_iso_8601": "2024-02-13T21:42:05.901029Z",
            "url": "https://files.pythonhosted.org/packages/28/ea/79c58ccf5669fd5678534eaef6f355fca7b02c87e1a8460221bc1e302172/llama_index_readers_reddit-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d94da2a4d2852fb5b88372bb56920175614f004db1ccabe9712a730d45da5b2",
                "md5": "e8749bfdfcf0e418d8160f4194b43e80",
                "sha256": "7e75654cb535e7503774fc489867c1e960d51112050baa205f8f54fb82febbc6"
            },
            "downloads": -1,
            "filename": "llama_index_readers_reddit-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e8749bfdfcf0e418d8160f4194b43e80",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<3.12",
            "size": 3286,
            "upload_time": "2024-02-13T21:42:07",
            "upload_time_iso_8601": "2024-02-13T21:42:07.552097Z",
            "url": "https://files.pythonhosted.org/packages/3d/94/da2a4d2852fb5b88372bb56920175614f004db1ccabe9712a730d45da5b2/llama_index_readers_reddit-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 21:42:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-reddit"
}
        
Elapsed time: 0.17943s