Skip to content

spoluan/experiment-chatbot

Repository files navigation

Simple Local Chatbot (Ollama)

A lightweight local chatbot that sends prompts directly to Ollama.

Features

  • Direct model chat (no retrieval, no vector database)
  • Web UI for chatting
  • Conversation history: create, resume, rename, delete, export
  • Per-conversation context profile overrides
  • CLI chat mode

Quick Start

1. Prerequisites

  • Ollama running locally
  • Python 3.8+

2. Setup

python3 -m venv env
source env/bin/activate
pip install -r requirements.txt

cp .env.example .env
ollama pull llama3.1:8b

3. Chat (CLI)

python scripts/chat.py --question "Hello"
python scripts/chat.py

4. Chat (Web)

python scripts/server.py

Open: http://localhost:8000

Run with Docker

1. Prerequisites

  • Docker + Docker Compose
  • Ollama running on your host machine

2. Configure .env

If your app runs in Docker and Ollama runs on your host, set:

OLLAMA_BASE_URL=http://host.docker.internal:11434
GENERATION_MODEL=llama3.1:8b
GENERATION_TEMPERATURE=0.2
GENERATION_TOP_P=0.9

3. Build and run

docker compose up --build

Open: http://localhost:8000

4. Stop

docker compose down

Notes:

  • ./data and ./config are mounted into the container, so conversations/profiles persist.
  • On Linux, host.docker.internal is mapped via extra_hosts in docker-compose.yml.

Screenshots

Web UI

Overview

Model Management

Chat with Profile

Configuration

Edit .env:

OLLAMA_BASE_URL=http://localhost:11434
GENERATION_MODEL=llama3.1:8b
GENERATION_TEMPERATURE=0.2
GENERATION_TOP_P=0.9

Profiles are in config/chat_profiles.json. Each profile supports:

  • system_prompt
  • answer_instruction
  • history_turns

API Endpoints

  • GET / - Web UI
  • POST /query - Ask a question
  • GET /chat/profiles - List profiles
  • POST /conversations - Create conversation
  • GET /conversations - List conversations
  • GET /conversations/{conversation_id} - Load conversation
  • PATCH /conversations/{conversation_id}/context - Update profile/history/prompt overrides
  • PATCH /conversations/{conversation_id} - Rename conversation
  • DELETE /conversations/{conversation_id} - Delete conversation
  • GET /conversations/{conversation_id}/export - Export conversation JSON
  • GET /health - Health check

About

Lightweight local chatbot built with FastAPI and Ollama. Features web UI, CLI mode, conversation persistence, and per-conversation context profiles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors