A plugin for llm to load Reddit threads as fragments
Project description
llm-fragments-reddit
A plugin for llm that loads Reddit threads as fragments, making it easy to analyze and summarize Reddit discussions with large language models.
Features
- Load entire Reddit threads (submission + comments) as LLM fragments
- Support for both Reddit URLs and submission IDs
- Preserves comment hierarchy with proper indentation
- Converts threads to clean Markdown format
- Handles deleted comments and "load more" placeholders gracefully
Installation
Install using pip:
llm install llm-fragments-reddit
Or for development:
git clone https://github.com/banteg/llm-fragments-reddit
cd llm-fragments-reddit
pip install -e .
Usage
The plugin adds a reddit fragment loader to the llm command. You can use it in two ways:
Using Reddit URLs
llm -f reddit:https://www.reddit.com/r/Python/comments/abc123/my_thread/ "summarize the key ideas"
Using Submission IDs
llm -f reddit:abc123 "extract the main arguments from this discussion"
How it works
The plugin:
- Fetches the Reddit thread using Reddit's JSON API
- Converts the submission title, self-text, and comment tree into Markdown
- Preserves comment hierarchy with indentation (2 spaces per nesting level)
- Each comment is formatted as:
- **u/username**: comment body - Returns the entire thread as a single fragment for LLM processing
Output Format
The generated fragment includes:
- Thread title as H1 header
- Original post content (if any)
- Nested comment tree with proper indentation
- Author attribution for each comment
Example output structure:
# DAE think Reddit is becoming too mainstream?
I've been on Reddit for 7 years (this is my alt account) and I swear the quality of discourse has really declined. Back in my day we had actual discussions instead of just memes and karma farming.
---
- **u/NostalgicRedditor2016**: This. So much this. I remember when you could have nuanced discussions without getting downvoted to oblivion.
- **u/ActuallyIm14**: OK boomer. Reddit was always trash, you just got older and realized it.
- **u/NostalgicRedditor2016**: I'm 23 but go off I guess
- **u/GrammarNaziPatrol**: *you're
- **u/NostalgicRedditor2016**: No, "you" is correct there. Maybe learn grammar before correcting others?
- **u/GrammarNaziPatrol**: Edit: Thanks for the gold, kind stranger!
- **u/RedditExpert2024**: Unpopular opinion but Reddit has always been a circlejerk. The real issue is people thinking upvotes = truth
- **u/PhilosophyUndergrad**: This is a profound observation. As Nietzsche once said... [3000 word comment about nihilism]
- **u/SkippedTheReading**: TL;DR?
- **u/PowerModerator**: Locked. Y'all can't behave.
Requirements
- Python ≥ 3.12
- llm ≥ 0.26
- requests ≥ 2.32.3
License
MIT License - see the source code for details.
Author
Created by banteg
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_fragments_reddit-0.1.1.tar.gz.
File metadata
- Download URL: llm_fragments_reddit-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae2a7656e70662855425f0ef215da17854a363b89be2cd8c5beb12e4c143d73c
|
|
| MD5 |
53baea42b9a6b82b8f608efbbe3732d3
|
|
| BLAKE2b-256 |
0495fd8d1099fe258102829fe36b2f359155b021271b1aba18f3da02f0ce6342
|
File details
Details for the file llm_fragments_reddit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llm_fragments_reddit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a91fbde5a8f3ff71fdcbac773b7c33c33158565dc6a45d568a82a5ef7354ab3
|
|
| MD5 |
9d07cd01fb3399eee87bf1d55171a1af
|
|
| BLAKE2b-256 |
772cbfca65766c2c64767d237d0a44db9214a136543074fd777388e9fdf708ce
|