Skip to main content

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:

pip 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:

  1. Fetches the Reddit thread using Reddit's JSON API
  2. Converts the submission title, self-text, and comment tree into Markdown
  3. Preserves comment hierarchy with indentation (2 spaces per nesting level)
  4. Each comment is formatted as: - **u/username**: comment body
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_fragments_reddit-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_fragments_reddit-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file llm_fragments_reddit-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llm_fragments_reddit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc233a3a929cf9a72dcaa7e99d8c55927b81defa1d0f83f14644b6636d307c11
MD5 9ec4870526a6afd61696a36a3e5a32f7
BLAKE2b-256 0a89e1fac39b9830bc7788fb1e010628c425f9228420a5f64e9b36348d45e6d6

See more details on using hashes here.

File details

Details for the file llm_fragments_reddit-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_fragments_reddit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a5dd3bec7501105d37d358aaa534d399c70ab9d5e1583b99c8f8b0fdc529b63
MD5 146d945d898e6f3d2de47f5a4ef78386
BLAKE2b-256 8dbaa8d62f33436b6ee460ad50649b64afaef2da7b0b24df2b5d623a5e331f40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page