A powerful Python script that analyzes Discord chat exports and generates comprehensive summaries using local LLM models through Ollama.
-
Smart Message Analysis: Processes Discord chat exports and generates structured analysis including:
- Concise technical discussion summaries
- FAQ compilation from discussions
- Help interaction tracking
- Action item extraction
-
Efficient Processing:
- Chunks messages for optimal processing
- Uses local LLM models via Ollama
- Progress tracking with rich CLI interface
- Graceful shutdown handling
-
Structured Output:
- Markdown formatted reports
- Categorized action items
- Clear help interaction summaries
- FAQ compilation
- Python 3.8+
- Ollama installed and running
- Required Python packages:
langchain_ollama python-dateutil rich pydantic
- Clone the repository or download the script
- Install required packages:
pip install langchain_ollama python-dateutil rich pydantic
- Ensure Ollama is installed and running with a compatible model (default: phi3-chat)
The Modelfile is configured for a Linux system. Edit the Modelfile for your system: https://github.com/ollama/ollama/blob/main/docs/modelfile.md
# Pull whatever model you want to use, phi3 worked best in our tests for summarizing
ollama run phi3:14b-medium-4k-instruct-q5_K_M
# Edit the Modelfile first for your system
ollama create phi3-chat -f Modelfile
Note: For exporting Discord Chats you can look into using the Discord API and make a bot. Code soon. If using DiscordChatExporter a preprocess script is provided to make a more compact version of the JSON file to save on tokens
Basic usage:
python summarize.py -i samples/chat_export.json -o /path/to/output.md
Arguments:
-i, --input
: Path to Discord chat export JSON file (required)-o, --output
: Path to save the analysis output file (optional)
If no output path is specified, the analysis will be printed to stdout.
The script generates a structured markdown report containing:
- Summary: Focused technical discussion overview
- FAQ: Important questions and answers from the chat
- Help Interactions: Tracking of community support
- Action Items: Categorized into:
- Technical Tasks
- Documentation Needs
- Feature Requests
Note: using https://github.com/njvack/markdown-to-json to convert to JSON to make embedding to Eliza knowledge easier
You can modify the script's behavior by adjusting:
- Model settings in
__init__
:self.model = ChatOllama( model=model_name, temperature=0.2, num_ctx=4096, ... )
- Chunk size in
_chunk_messages
- Analysis structure in
format_structured_prompt
- Output formatting in
_format_markdown
The script includes:
- Graceful CTRL+C handling
- LLM initialization error catching
- Progress tracking
- Chunk processing error recovery
Contributions are welcome! Please feel free to submit a Pull Request.
- Explore structured outputs from ollama
- Integrate into the Eliza framework