How d-evil0per/ollama-chat-console works
Project type and purpose
• This is a single‐page web application (a Streamlit frontend) that acts as a chat client for locally hosted Ollama LLMs.
• Purpose: provide a responsive UI for sending prompts, adjusting parameters, viewing/streaming responses, handling chat history (export/clear), and optionally uploading files to multimodal models.
File structure
• Top‐level files:
• app.py – the Streamlit “frontend” logic, UI layout, state management, user interactions.
• OllamaClient.py – a thin client library encapsulating HTTP/streaming calls to the local Ollama server.
• requirements.txt – Python dependencies (streamlit, requests or httpx, etc.).
• .streamlit/config.toml – Streamlit configuration (port, theme, etc.).
• image/ – static assets for README and in‐app screenshots and logos.
• No separate “backend” service – the Streamlit app itself hosts the UI and orchestrates calls to the Ollama server.
README for additional insights
• Confirms core flows: connect to localhost:11434, choose model, set parameters, send user messages, stream or batch receive.
• Chat history lives in UI state and can be exported to JSON.
• Supports file attachments for multimodal models.
a. Main components:
1. User’s Browser / Client Interface (served by Streamlit)
2. Streamlit App (app.py)
3. OllamaClient Library (OllamaClient.py)
4. Local Ollama Server (localhost:11434)
5. Local LLM Models & Runtimes (inside Ollama Server)
6. Chat History Store (in‐memory state + JSON export)
7. File Upload Handler / Static Assets (image/)
b. Interactions & Data Flow:
• User inputs in the Browser → Streamlit App (HTTP/websocket)
• Streamlit App invokes OllamaClient methods → HTTP REST or streaming gRPC to Ollama Server
• Ollama Server processes through the selected model → streams or returns full response
• Streamlit App updates UI with responses; app state holds chat history
• On “export” action, Streamlit App serializes state → JSON file download
• File uploads from Browser → Streamlit App → forwarded to Ollama Server if model supports multimodal
c. Architectural patterns & design principles:
• Monolithic web app (no separate microservices)
• Client‐server over HTTP/HTTPS for UI
• Adapter pattern: OllamaClient abstracts protocol details
• State‐driven UI (Streamlit’s reactive paradigm)
d. Key technologies & libraries:
• Streamlit – UI & session management
• Python stdlib / third‐party HTTP client (inside OllamaClient.py)
• Ollama Server – local LLM hosting
• JSON – chat history export format
• Both real‐time (streaming) and batch response flows
• File‐upload path distinctly if multimodal models are involved
• In‐app state (chat history) and the export mechanism