Skip to content

Web application

A browser-based reference implementation of conversational RAG, built on a Starlette backend with pydantic-ai's AGUIAdapter and a Next.js / CopilotKit frontend. It lives in the app/ directory of the haiku.rag repository.

It is a starting point for your own deployment. The terminal equivalent is Chat.

No authentication

An illustrative example meant as a starting point, with no authentication. The compose files bind the frontend and backend to 127.0.0.1. The frontend proxies every backend route, so don't expose either to an untrusted network.

It streams answers and tool calls, shows expandable citations with visual grounding, restricts searches through a document filter, and keeps sessions in the browser with markdown export.

Quick start

cd app
cp .env.example .env
cp haiku.rag.yaml.example haiku.rag.yaml
docker compose up -d --build
# with hot reload instead: docker compose -f docker-compose.dev.yml up -d --build

The frontend is at http://localhost:3000 and the backend at http://localhost:8001. The app needs an existing database, created with the haiku-rag CLI.

Configuration

.env in the app/ directory holds the secrets and the database path:

# API keys for the providers haiku.rag.yaml uses (none for Ollama)
ANTHROPIC_API_KEY=your-anthropic-key
OPENAI_API_KEY=your-openai-key

# Host path of the LanceDB database, mounted at /data
DB_VOLUME=/path/to/your/haiku.rag.lancedb

# Optional: Logfire for observability
LOGFIRE_TOKEN=your-logfire-token

haiku.rag.yaml, copied from haiku.rag.yaml.example, places the database at /data and configures the models. The compose files point HAIKU_RAG_CONFIG_PATH at it. The example uses Ollama on the host through providers.ollama.base_url: http://host.docker.internal:11434, which takes precedence over OLLAMA_BASE_URL:

lancedb:
  databases:
    haiku.rag: /data

qa:
  model:
    provider: ollama
    name: gpt-oss

embeddings:
  model:
    provider: ollama
    name: qwen3-embedding:4b
    vector_dim: 2560

Outside compose, the backend loads its configuration like the CLI: HAIKU_RAG_CONFIG_PATH, then ./haiku.rag.yaml, then the platform directory.

API endpoints

Endpoint Method Description
/v1/chat/stream POST AG-UI chat streaming
/api/documents GET List all documents
/api/info GET Database statistics
/api/visualize/{chunk_id} GET Visual grounding images (base64)
/health GET Health check

Development

The backend reloads automatically on file changes. For frontend changes:

docker compose -f docker-compose.dev.yml up -d --build frontend

If LOGFIRE_TOKEN is set, LLM calls are traced and available in the Logfire dashboard.