How harieswarreddygelli/ai-chatbot works
Local AI is a Flask chatbot with a browser chat interface, locally hosted Ollama inference, persistent conversations and memory, selectable assistant personalities, and optional web search with source references. The main workflow sends a user message through the browser to the Flask backend, which manages chat context and memory, selects a personality, optionally gathers web information, and streams a response from Ollama back to the browser. The backend excerpt is partial, so internal wiring beyond the documented workflow is shown only where supported.
Main entry points: app.py Chat orchestration · script.js Chat UI · memory.json Persistent memory · memory.py Chat history
Components 18
Chat interface
- Chat UI
static/script.js - Chat page
templates/index.html - Markdown renderer
static/markdown.js
Conversation backend
- Flask backend
app.py - Chat orchestration
app.py - Personality prompts
chatbot/personalities.py - Web search
app.py
Memory and history
- Memory extraction
app.py - Memory center API
app.py - Chat history
chatbot/memory.py - Chat summaries
chatbot/summary.py - Basic memory helpers
chatbot/long_memory.py - Saved chats
chats - Persistent memory
data/memory.json - Saved summaries
data/summaries
AI and web integrations
- Ollama
- DuckDuckGo
Other components
- User
Connections 19
- User → Chat UI: sends messages
- Flask backend → Chat page: renders page
- Chat UI → Flask backend: calls API
- Flask backend → Chat orchestration: dispatches chat
- Chat orchestration → Chat history: loads and saves
- Chat orchestration → Personality prompts: selects prompt
- Chat orchestration → Memory extraction: updates memory
- Chat orchestration → Web search: requests search
- Chat orchestration → Ollama: streams inference
- Ollama → Chat orchestration: returns tokens
- Chat orchestration → Chat UI: streams response
- Chat UI → Markdown renderer: renders responses
- Web search → DuckDuckGo: queries web
- Memory extraction → Persistent memory: persists memory
- Memory center API → Persistent memory: reads and edits
- Chat UI → Memory center API: manages memories
- Chat history → Saved chats: reads and writes
- Chat summaries → Saved summaries: reads and writes
- Basic memory helpers → Persistent memory: reads and writes