Update examples to use the YAML config. Needs checking post release as we use the published docker image
This commit is contained in:
parent
268c26eb4e
commit
0e1f827da4
9 changed files with 79 additions and 87 deletions
|
|
@ -25,6 +25,13 @@ wheels/
|
||||||
venv/
|
venv/
|
||||||
env/
|
env/
|
||||||
|
|
||||||
|
# Node.js
|
||||||
|
node_modules/
|
||||||
|
.next/
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
# Data
|
# Data
|
||||||
*.lancedb/
|
*.lancedb/
|
||||||
data/
|
data/
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,3 @@
|
||||||
# QA Provider for the research agent (ollama, openai, anthropic, etc.)
|
|
||||||
QA_PROVIDER=ollama
|
|
||||||
|
|
||||||
# QA Model name
|
|
||||||
QA_MODEL=gpt-oss:latest
|
|
||||||
|
|
||||||
# Ollama base URL (only needed if using ollama provider)
|
|
||||||
# For Docker: http://host.docker.internal:11434
|
|
||||||
# For local development: http://localhost:11434
|
|
||||||
OLLAMA_BASE_URL=http://host.docker.internal:11434
|
|
||||||
|
|
||||||
# Path to the LanceDB database
|
# Path to the LanceDB database
|
||||||
# For Docker: /app/data/haiku_rag.lancedb
|
# For Docker: /app/data/haiku_rag.lancedb
|
||||||
# For local development: Use absolute path to existing database
|
# For local development: Use absolute path to existing database
|
||||||
|
|
@ -17,7 +6,5 @@ DB_PATH=~/SOME_FOLDER/haiku.rag.lancedb
|
||||||
# API keys (set as needed for your QA provider)
|
# API keys (set as needed for your QA provider)
|
||||||
# OPENAI_API_KEY=your-key-here
|
# OPENAI_API_KEY=your-key-here
|
||||||
# ANTHROPIC_API_KEY=your-key-here
|
# ANTHROPIC_API_KEY=your-key-here
|
||||||
|
# VOYAGE_API_KEY=your-key-here
|
||||||
# Embedding provider configuration (optional, defaults will be used)
|
# CO_API_KEY=your-key-here
|
||||||
# EMBEDDING_PROVIDER=openai
|
|
||||||
# EMBEDDING_MODEL=text-embedding-3-small
|
|
||||||
|
|
|
||||||
3
examples/ag-ui-research/.gitignore
vendored
Normal file
3
examples/ag-ui-research/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
haiku.rag.yaml
|
||||||
|
.env
|
||||||
|
data/
|
||||||
|
|
@ -30,19 +30,27 @@ Research assistant powered by [haiku.rag](https://ggozad.github.io/haiku.rag/),
|
||||||
haiku-rag add-src document.pdf --db data/haiku_rag.lancedb
|
haiku-rag add-src document.pdf --db data/haiku_rag.lancedb
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Configure environment** (optional)
|
2. **Configure haiku.rag**
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env
|
cp haiku.rag.yaml.example haiku.rag.yaml
|
||||||
# Edit .env to customize provider/model
|
# Edit haiku.rag.yaml to customize provider/model
|
||||||
```
|
```
|
||||||
See [haiku.rag configuration](https://ggozad.github.io/haiku.rag/configuration/) for details.
|
See [haiku.rag configuration](https://ggozad.github.io/haiku.rag/configuration/) for details.
|
||||||
|
|
||||||
3. **Start the application**
|
3. **Set API keys** (if using non-Ollama providers)
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
# Edit .env to set your API keys
|
||||||
|
export OPENAI_API_KEY=your-key-here
|
||||||
|
export ANTHROPIC_API_KEY=your-key-here
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Start the application**
|
||||||
```bash
|
```bash
|
||||||
docker compose up --build
|
docker compose up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Access the interface**
|
5. **Access the interface**
|
||||||
- Frontend: http://localhost:3000
|
- Frontend: http://localhost:3000
|
||||||
- Backend health: http://localhost:8000/health
|
- Backend health: http://localhost:8000/health
|
||||||
|
|
||||||
|
|
@ -60,6 +68,7 @@ Research assistant powered by [haiku.rag](https://ggozad.github.io/haiku.rag/),
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
- **Backend** (Python): Pydantic AI agent with haiku.rag integration
|
- **Backend** (Python): Pydantic AI agent with haiku.rag integration
|
||||||
|
- Uses published `ghcr.io/ggozad/haiku.rag:latest` Docker image as base
|
||||||
- `agent.py`: Research agent with tool definitions
|
- `agent.py`: Research agent with tool definitions
|
||||||
- `main.py`: Starlette app serving AG-UI protocol
|
- `main.py`: Starlette app serving AG-UI protocol
|
||||||
|
|
||||||
|
|
@ -70,11 +79,15 @@ Research assistant powered by [haiku.rag](https://ggozad.github.io/haiku.rag/),
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
Configuration is done through `haiku.rag.yaml` (see `haiku.rag.yaml.example`):
|
||||||
|
|
||||||
|
- `qa.provider`: LLM provider (default: `ollama`)
|
||||||
|
- `qa.model`: Model name (default: `gpt-oss:latest`)
|
||||||
|
- `providers.ollama.base_url`: Ollama endpoint (default: `http://host.docker.internal:11434`)
|
||||||
|
|
||||||
Environment variables (see `.env.example`):
|
Environment variables (see `.env.example`):
|
||||||
|
|
||||||
- `DB_PATH`: Path to haiku.rag database (default: `haiku_rag.lancedb`)
|
- `DB_PATH`: Path to haiku.rag database (default: `haiku_rag.lancedb`)
|
||||||
- `QA_PROVIDER`: LLM provider (default: `ollama`)
|
- `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`: API keys for cloud providers
|
||||||
- `QA_MODEL`: Model name (default: `gpt-oss:latest`)
|
|
||||||
- `OLLAMA_BASE_URL`: Ollama endpoint (default: `http://host.docker.internal:11434`)
|
|
||||||
|
|
||||||
For other providers (OpenAI, Anthropic, etc.), see [haiku.rag configuration docs](https://ggozad.github.io/haiku.rag/configuration/).
|
For full configuration options, see [haiku.rag configuration docs](https://ggozad.github.io/haiku.rag/configuration/).
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,15 @@
|
||||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
FROM ghcr.io/ggozad/haiku.rag:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Enable bytecode compilation
|
# Copy backend application files
|
||||||
ENV UV_COMPILE_BYTECODE=1
|
COPY agent.py main.py ./
|
||||||
|
COPY pyproject.toml uv.lock ./
|
||||||
|
|
||||||
# Copy from the cache instead of linking since it's a mounted volume
|
# Install backend dependencies into the existing haiku.rag venv
|
||||||
ENV UV_LINK_MODE=copy
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
||||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
|
||||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
|
||||||
uv sync --frozen --no-install-project --no-dev
|
|
||||||
|
|
||||||
# Copy the project into the image
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Sync the project
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
||||||
uv sync --frozen --no-dev
|
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run with uv
|
# Run with uvicorn
|
||||||
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,15 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
- QA_PROVIDER=${QA_PROVIDER:-ollama}
|
|
||||||
- QA_MODEL=${QA_MODEL:-gpt-oss:latest}
|
|
||||||
- DB_PATH=/app/data/haiku.rag.lancedb
|
- DB_PATH=/app/data/haiku.rag.lancedb
|
||||||
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
|
# API keys (set these in your shell or .env file)
|
||||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend:/app
|
- ./backend:/app
|
||||||
- /app/.venv
|
- /app/.venv
|
||||||
- ${DB_PATH}:/app/data/haiku.rag.lancedb
|
- ${DB_PATH}:/app/data/haiku.rag.lancedb
|
||||||
|
- ./haiku.rag.yaml:/app/haiku.rag.yaml:ro # Mount config file
|
||||||
networks:
|
networks:
|
||||||
- ag-ui-network
|
- ag-ui-network
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
|
|
|
||||||
20
examples/ag-ui-research/haiku.rag.yaml.example
Normal file
20
examples/ag-ui-research/haiku.rag.yaml.example
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# haiku.rag configuration for ag-ui-research example
|
||||||
|
# Copy to haiku.rag.yaml and customize
|
||||||
|
|
||||||
|
qa:
|
||||||
|
provider: ollama
|
||||||
|
model: gpt-oss:latest
|
||||||
|
|
||||||
|
providers:
|
||||||
|
ollama:
|
||||||
|
base_url: http://host.docker.internal:11434
|
||||||
|
|
||||||
|
# For OpenAI:
|
||||||
|
# qa:
|
||||||
|
# provider: openai
|
||||||
|
# model: gpt-4o-mini
|
||||||
|
|
||||||
|
# For Anthropic:
|
||||||
|
# qa:
|
||||||
|
# provider: anthropic
|
||||||
|
# model: claude-3-5-haiku-20241022
|
||||||
|
|
@ -6,7 +6,7 @@ Run haiku.rag with file monitoring, MCP server, and A2A agent.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p data docs
|
mkdir -p data docs
|
||||||
cp .env.example .env # Edit if needed
|
cp haiku.rag.yaml.example haiku.rag.yaml # Edit as needed
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -35,10 +35,18 @@ docker compose exec haiku-rag haiku-rag a2aclient --url http://localhost:8000
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Edit `.env` or `docker-compose.yml` to configure providers. See the [Configuration documentation](https://ggozad.github.io/haiku.rag/configuration/) for all options.
|
Edit `haiku.rag.yaml` to configure providers, embeddings, and other settings. See the [Configuration documentation](https://ggozad.github.io/haiku.rag/configuration/) for all options.
|
||||||
|
|
||||||
Default setup uses Ollama on the host (`host.docker.internal:11434`).
|
Default setup uses Ollama on the host (`host.docker.internal:11434`).
|
||||||
|
|
||||||
|
For API keys (OpenAI, Anthropic, etc.), set them as environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export OPENAI_API_KEY=your-key-here
|
||||||
|
export ANTHROPIC_API_KEY=your-key-here
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/)
|
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/)
|
||||||
|
|
|
||||||
|
|
@ -10,46 +10,13 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data # Persist database
|
- ./data:/data # Persist database
|
||||||
- ./docs:/docs # Mount documents directory for monitoring
|
- ./docs:/docs # Mount documents directory for monitoring
|
||||||
|
- ./haiku.rag.yaml:/app/haiku.rag.yaml:ro # Mount config file
|
||||||
environment:
|
environment:
|
||||||
# Database directory
|
# API keys (set as needed)
|
||||||
- DEFAULT_DATA_DIR=/data
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||||
# File monitoring
|
- VOYAGE_API_KEY=${VOYAGE_API_KEY}
|
||||||
- MONITOR_DIRECTORIES=/docs
|
- CO_API_KEY=${CO_API_KEY}
|
||||||
|
|
||||||
# Set the Ollama base url for Ollama defaults
|
|
||||||
- OLLAMA_BASE_URL=http://host.docker.internal:11434
|
|
||||||
|
|
||||||
# Embeddings provider (choose one)
|
|
||||||
# For OpenAI:
|
|
||||||
# - EMBEDDINGS_PROVIDER=openai
|
|
||||||
# - EMBEDDINGS_MODEL=text-embedding-3-small
|
|
||||||
# - OPENAI_API_KEY=your-key-here
|
|
||||||
|
|
||||||
# For VoyageAI:
|
|
||||||
# - EMBEDDINGS_PROVIDER=voyageai
|
|
||||||
# - EMBEDDINGS_MODEL=voyage-3
|
|
||||||
# - VOYAGE_API_KEY=your-key-here
|
|
||||||
|
|
||||||
# QA provider (uses Pydantic AI)
|
|
||||||
# - QA_PROVIDER=ollama
|
|
||||||
|
|
||||||
# For OpenAI:
|
|
||||||
# - QA_PROVIDER=openai
|
|
||||||
# - QA_MODEL=gpt-4o-mini
|
|
||||||
# - OPENAI_API_KEY=your-key-here
|
|
||||||
|
|
||||||
# Reranking (optional)
|
|
||||||
# - RERANKING_PROVIDER=mxbai
|
|
||||||
# - RERANKING_MODEL=mixedbread-ai/mxbai-rerank-large-v1
|
|
||||||
# - RERANKING_BASE_URL=http://host.docker.internal:11434
|
|
||||||
|
|
||||||
# Research agent (optional, defaults to QA provider/model)
|
|
||||||
# - RESEARCH_PROVIDER=openai
|
|
||||||
# - RESEARCH_MODEL=gpt-4o
|
|
||||||
|
|
||||||
# Environment
|
|
||||||
- ENV=production
|
|
||||||
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue