How deep-diver/llm-as-chatbot works
This repository serves instruction-tuned language models as chatbots through two front ends: a Gradio application and a Discord bot. Both rely on model selection/loading, model-specific conversation formatting, and text generation; search can augment answers. The graph preserves the documented model zoo and both user-facing routes. Some subsystem links are based on the SOURCE INDEX or README rather than complete excerpts, so uncertain implementation details are omitted.
Main entry points: chats Model chat adapters · discord_app.py Discord bot · global_vars.py Model runtime · req.py Discord requests
Components 16
Chat front ends
- Gradio UI
app.py - Discord bot
discord_app.py - Discord requests
discordbot/req.py - Request flags
discordbot/flags.py
Conversation handling
- Model chat router
chats/central.py - Model chat adapters
chats - Prompt and context
chats/utils.py
Models and inference
- Generation inputs
chats/pre.py - Stream formatting
chats/post.py - Batch generation
gens/batch_gen.py - Model runtime
global_vars.py - Model definitions
models
External services
- Serper search
- Discord service
- Hugging Face Hub
Other components
- Chat user
Connections 19
- Chat user → Gradio UI: chats through
- Chat user → Discord bot: mentions bot
- Gradio UI → Model chat router: routes chat
app.py - Discord bot → Discord requests: handles requests
discord_app.py - Discord bot → Model runtime: initializes model
discord_app.py - Discord requests → Request flags: parses options
discordbot/req.py - Discord requests → Prompt and context: builds prompt
- Discord requests → Model runtime: generates response
discordbot/req.py - Model chat router → Model chat adapters: dispatches model
chats/central.py - Model chat adapters → Prompt and context: builds prompts
chats/xgen.py - Model chat adapters → Generation inputs: prepares generation
chats/xgen.py - Model chat adapters → Stream formatting: strips response
chats/xgen.py - Model chat adapters → Batch generation: calls batch generation
chats/alpaca.py - Generation inputs → Model runtime: invokes generation
chats/pre.py - Model runtime → Model definitions: loads model implementation
global_vars.py - Model runtime → Hugging Face Hub: loads model weights
- Model chat adapters → Serper search: searches when enabled
chats/utils.py - Discord bot → Serper search: searches when enabled
- Discord bot → Discord service: connects bot