Skip to main content

Reddit Reader

pip install llama-index-readers-reddit

For any subreddit(s) you're interested in, search for relevant posts using keyword(s) and load the resulting text in the post 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/
  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 respectively.
  5. Additionally store the environment variables REDDIT_USERNAME and REDDIT_PASSWORD, which correspond to the credentials for your Reddit account.

Usage

LlamaIndex

from llama_index.core import VectorStoreIndex, download_loader

from llama_index.readers.reddit import 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

from llama_index.core import VectorStoreIndex, download_loader

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

from llama_index.readers.reddit import 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.

Metadata

Release files for llama-index-readers-reddit 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-readers-reddit 0.7.0
File Size Uploaded Provenance Actions
llama_index_readers_reddit-0.7.0.tar.gz 4.6 kB Without provenance Details for llama_index_readers_reddit-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-readers-reddit 0.7.0
File Interpreter ABI Platform Actions
llama_index_readers_reddit-0.7.0-py3-none-any.whl Python 3 none any Details for llama_index_readers_reddit-0.7.0-py3-none-any.whl

Total release size: 8.8 kB

Release files / llama_index_readers_reddit-0.7.0.tar.gz

Download URL llama_index_readers_reddit-0.7.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3eb03f137b2e62e7b3980fe3c0406068e3dd5b75a16d4cc26b967066c0850ee3
BLAKE2b-256 checksum
How to use checksums
985b818f8d2d3bed5e005f667529c815f61fb6111ba3b75fd26e45673296e7d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_readers_reddit-0.7.0-py3-none-any.whl

Download URL llama_index_readers_reddit-0.7.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c16d8e2cd87665cc6aed3703c66f020108673b0d342489d9659aa1a8f05a7b4a
BLAKE2b-256 checksum
How to use checksums
716fb2c9154b3f47d7e1e29d00a4d10e86e71a9ff9224c4c7fd87166a67a19f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-readers-reddit 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page