Skip to content

ulfaslak/what-the-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

What The Chat ๐Ÿ’ฌ

A modular Python package for fetching and summarizing chat history from Discord or Slack channels using AI.

example.mp4

CI Python 3.10-3.12 License: MIT Beta codecov

โš ๏ธ Beta Notice: This package is currently in beta. While core functionality works, some features may be unstable or incomplete. Use at your own discretion and expect potential breaking changes in future releases.

๐ŸŒŸ Overview

Transform your Discord and Slack conversations into actionable insights! This package provides:

๐Ÿ“ฅ Fetch all messages from Discord/Slack channels since any date
๐Ÿงต Include messages from threads within channels
๐Ÿค– Generate intelligent summaries using local or remote LLMs
๐Ÿ’พ Save both full chat history and summaries to files
๐Ÿ’ญ Chat interactively with your conversation history
๐Ÿ”ง Import into your own projects and build cool things with it (bots, web apps, etc.)

โœจ Features

๐Ÿ”— Versatile

  • Discord and Slack channel integration
  • Thread support - automatically collects messages from all threads
  • User reference standardization - clean, readable output

๐Ÿง  Intelligent Summarization

  • Smart summarization based on timespan:
    • ๐Ÿ“‹ Project Event Update (0-2 days)
    • ๐Ÿ“Š Periodical Digest (3-6 days)
    • ๐Ÿ“ˆ Full Project Status Summary (7+ days)
  • Model flexibility - local models (Ollama) or remote (OpenAI)
  • User-friendly output - replaces IDs with actual usernames

๐Ÿ’ฌ Interactive Features

  • Chat with your history - ask questions about conversations
  • Colorful terminal output with clear visual cues
  • Graceful exit handling - no more ugly tracebacks
  • Export formats - markdown files with accurate timestamps

๐Ÿ› ๏ธ Developer Friendly

  • Modular architecture - clean separation of concerns
  • Python package - easy integration into other projects
  • Explicit token handling - no hidden environment dependencies
  • Extensible design - perfect for building bots and web apps

๐Ÿš€ Quick Start

Originally created for personal use as a CLI application, this package has been refactored to also work as an importable Python package for your own projects.

๐Ÿ’ป Running the CLI Application

1. Clone and Install

git clone https://github.com/yourusername/what-the-chat.git
cd what-the-chat

2. Choose Installation Method

๐ŸŽฏ Option A: Using pixi (recommended)
pixi install
๐Ÿ Option B: Using pip
pip install -e .

3. Setup Environment Create a .env file with your tokens:

DISCORD_TOKEN=your_discord_bot_token
SLACK_TOKEN=your_slack_bot_token
OPENAI_API_KEY=your_openai_api_key  # Only needed for remote models

๐Ÿ“ฆ Installing as a Package

Add to your own projects:

pip install git+https://github.com/ulfaslak/what-the-chat.git

๐Ÿ’ก Usage Examples

๐Ÿ–ฅ๏ธ CLI Application

๐ŸŽฏ Basic Usage

Get a 30-day summary with interactive chat:

# Using pixi
pixi run python apps/launch_cli.py --since-days 30 --channel 123456789012345678 --chat

# Or direct script execution
python apps/launch_cli.py --since-days 30 --channel 123456789012345678 --chat

Slack channels:

python apps/launch_cli.py --since-days 30 --platform slack --channel general --chat

โœจ What happens:

  1. ๐Ÿ“ฅ Fetches messages from the specified channel for the last 30 days
  2. ๐Ÿค– Generates an intelligent summary of the chat history
  3. ๐Ÿ’ฌ Starts an interactive chat session for Q&A

๐Ÿ’พ Saving to Files

Save everything for later analysis:

python apps/launch_cli.py --since-days 30 --channel 123456789012345678 \
  --dump-file ./output --dump-collected-chat-history

๐Ÿ“ Creates:

  • discord_history_summary_[channel]_[dates].md - AI-generated summary
  • discord_history_[channel]_[dates].md - Full conversation log

๐ŸŒ Using Remote Models

Switch to powerful cloud models:

python apps/launch_cli.py --since-days 30 --channel 123456789012345678 \
  --model-source remote --model gpt-4o

๐Ÿ Python Package Integration

Build What The Chat into your own applications:

import os
from datetime import datetime, timedelta
from what_the_chat import DiscordPlatform, SlackPlatform, SummarizationService, ChatService

# Get tokens and API keys explicitly
discord_token = os.getenv("DISCORD_TOKEN")  # or however you manage secrets
slack_token = os.getenv("SLACK_TOKEN")
openai_api_key = os.getenv("OPENAI_API_KEY")

# Discord example with explicit token
discord = DiscordPlatform(discord_token)
since_date = datetime.now() - timedelta(days=7)

# Fetch Discord messages (in an async context)
chat_history, first_date = await discord.fetch_messages_with_token(channel_id, since_date)
user_mapping = discord.get_user_mapping()

# Or Slack example with explicit token
slack = SlackPlatform(slack_token)
chat_history, first_date = slack.fetch_messages_with_token("general", since_date)
user_mapping = slack.get_user_mapping()

# Generate summary with explicit API key
summarizer = SummarizationService(model_source="remote", model="gpt-4o", api_key=openai_api_key)
summary = summarizer.generate_summary(chat_history, user_mapping)

# Start interactive chat with explicit API key
chat_service = ChatService(model_source="remote", model="gpt-4o", api_key=openai_api_key)
chat_service.start_interactive_session(chat_history, user_mapping)

# For local models, no API key needed
local_summarizer = SummarizationService(model_source="local", model="deepseek-r1-distill-qwen-7b")
local_summary = local_summarizer.generate_summary(chat_history, user_mapping)

โš™๏ธ Command Line Arguments

Argument Description Required Default
--since-days ๐Ÿ“… Number of days to look back โœ… -
--platform ๐Ÿ”— Platform (discord/slack) - discord
--channel ๐Ÿ“บ Channel ID or name โœ… -
--model-source ๐Ÿง  Model source (local/remote) - local
--model ๐Ÿค– Specific model name - deepseek-r1-distill-qwen-7b
--dump-file ๐Ÿ’พ Save summary to file - -
--dump-collected-chat-history ๐Ÿ“„ Save full chat history - false
--chat ๐Ÿ’ฌ Start interactive chat - false

๐Ÿ’ฌ Interactive Chat Commands

Once you're in the chat session, use these commands:

Command Description
help ๐Ÿ“– Show available commands
exit, quit, q ๐Ÿ‘‹ End chat gracefully
summary ๐Ÿ“‹ Generate new summary
users ๐Ÿ‘ฅ List all users in chat
Ctrl+C โšก Quick exit

๐Ÿ”ง Setup Guides

๐ŸŽฎ Discord Bot Setup
  1. Create a Discord application at Discord Developer Portal
  2. Create a bot for your application
  3. Enable the following intents:
    • โœ… Message Content Intent
  4. Generate a token for your bot
  5. Invite the bot with Read Message History permissions
๐Ÿ’ผ Slack Bot Setup
  1. Create a Slack app at Slack API
  2. Add these OAuth scopes:
    • โœ… channels:history - read public channels
    • โœ… groups:history - read private channels
    • โœ… im:history - read direct messages
    • โœ… mpim:history - read group direct messages
    • โœ… users:read - get user information
  3. Install the app to your workspace
  4. Copy the Bot User OAuth Token to your .env file as SLACK_TOKEN

๐Ÿงช Testing & CI

This package includes a comprehensive test suite with automated CI/CD:

Running Tests Locally

# Run all tests
pixi run -e test pytest tests/ -v

# Run with coverage
pixi run -e test pytest tests/ --cov=what_the_chat --cov-report=term

# Run specific test file
pixi run -e test pytest tests/test_models.py -v

Automated Testing

  • โœ… GitHub Actions CI - Automated testing using pixi environments
  • โœ… Test Coverage - Reports sent to Codecov
  • โœ… Package Installation - Verifies pixi installation and imports work
  • โœ… Import Validation - Ensures all classes import correctly
  • โœ… Dependency Caching - Fast CI with pixi environment caching
  • โœ… Python Version Management - pixi automatically manages Python versions

Status badges in the header show real-time build and coverage status!

๐Ÿค Contributing

Contributions are most welcome! Please feel free to submit a Pull Request.




โญ If this project helped you, please consider giving it a star! โญ

About

A small application that summarizes conversation in a Discord channel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages