Agentic Retrieval Augmented Generation (RAG) with LanceDB
Project description
Haiku RAG
Retrieval-Augmented Generation (RAG) library built on LanceDB.
haiku.rag is a Retrieval-Augmented Generation (RAG) library built to work with LanceDB as a local vector database. It uses LanceDB for storing embeddings and performs semantic (vector) search as well as full-text search combined through native hybrid search with Reciprocal Rank Fusion. Both open-source (Ollama) as well as commercial (OpenAI, VoyageAI) embedding providers are supported.
Features
- Local LanceDB: No external servers required, supports also LanceDB cloud storage, S3, Google Cloud & Azure
- Multiple embedding providers: Ollama, VoyageAI, OpenAI, vLLM
- Multiple QA providers: Any provider/model supported by Pydantic AI
- Native hybrid search: Vector + full-text search with native LanceDB RRF reranking
- Reranking: Default search result reranking with MixedBread AI, Cohere, Zero Entropy, or vLLM
- Question answering: Built-in QA agents on your documents
- Research graph (multi‑agent): Plan → Search → Evaluate → Synthesize with agentic AI
- File monitoring: Auto-index files when run as server
- CLI & Python API: Use from command line or Python
- MCP server: Expose as tools for AI assistants
- Flexible document processing: Local (docling) or remote (docling-serve) processing
Installation
Python 3.12 or newer required
Full Package (Recommended)
uv pip install haiku.rag
Includes all features: document processing, all embedding providers, and rerankers.
Slim Package (Minimal Dependencies)
uv pip install haiku.rag-slim
Install only the extras you need. See the Installation documentation for available options
Quick Start
# Add documents
haiku-rag add "Your content here"
haiku-rag add "Your content here" --meta author=alice --meta topic=notes
haiku-rag add-src document.pdf --meta source=manual
# Search
haiku-rag search "query"
# Search with filters
haiku-rag search "query" --filter "uri LIKE '%.pdf' AND title LIKE '%paper%'"
# Ask questions
haiku-rag ask "Who is the author of haiku.rag?"
# Ask questions with citations
haiku-rag ask "Who is the author of haiku.rag?" --cite
# Deep QA (multi-agent question decomposition)
haiku-rag ask "Who is the author of haiku.rag?" --deep --cite
# Deep QA with verbose output
haiku-rag ask "Who is the author of haiku.rag?" --deep --verbose
# Multi‑agent research (iterative plan/search/evaluate)
haiku-rag research \
"What are the main drivers and trends of global temperature anomalies since 1990?" \
--max-iterations 2 \
--confidence-threshold 0.8 \
--max-concurrency 3 \
--verbose
# Rebuild database (re-chunk and re-embed all documents)
haiku-rag rebuild
# Start server with file monitoring
haiku-rag serve --monitor
To customize settings, create a haiku.rag.yaml config file (see Configuration).
Python Usage
from haiku.rag.client import HaikuRAG
from haiku.rag.config import Config
from haiku.rag.graph.agui import stream_graph
from haiku.rag.graph.research import (
ResearchContext,
ResearchDeps,
ResearchState,
build_research_graph,
)
async with HaikuRAG("database.lancedb") as client:
# Add document
doc = await client.create_document("Your content")
# Search (reranking enabled by default)
results = await client.search("query")
for chunk, score in results:
print(f"{score:.3f}: {chunk.content}")
# Ask questions
answer = await client.ask("Who is the author of haiku.rag?")
print(answer)
# Ask questions with citations
answer = await client.ask("Who is the author of haiku.rag?", cite=True)
print(answer)
# Multi‑agent research pipeline (Plan → Search → Evaluate → Synthesize)
# Graph settings (provider, model, max_iterations, etc.) come from config
graph = build_research_graph(config=Config)
question = (
"What are the main drivers and trends of global temperature "
"anomalies since 1990?"
)
context = ResearchContext(original_question=question)
state = ResearchState.from_config(context=context, config=Config)
deps = ResearchDeps(client=client)
# Blocking run (final result only)
report = await graph.run(state=state, deps=deps)
print(report.title)
# Streaming progress (AG-UI events)
async for event in stream_graph(graph, state, deps):
if event["type"] == "STEP_STARTED":
print(f"Starting step: {event['stepName']}")
elif event["type"] == "ACTIVITY_SNAPSHOT":
print(f" {event['content']}")
elif event["type"] == "RUN_FINISHED":
print("\nResearch complete!\n")
result = event["result"]
print(result["title"])
print(result["executive_summary"])
MCP Server
Use with AI assistants like Claude Desktop:
haiku-rag serve --stdio
Provides tools for document management and search directly in your AI assistant.
Examples
See the examples directory for working examples:
- Interactive Research Assistant - Full-stack research assistant with Pydantic AI and AG-UI featuring human-in-the-loop approval and real-time state synchronization
- Docker Setup - Complete Docker deployment with file monitoring and MCP server
- A2A Server - Self-contained A2A protocol server package with conversational agent interface
Documentation
Full documentation at: https://ggozad.github.io/haiku.rag/
- Installation - Provider setup
- Configuration - YAML configuration
- CLI - Command reference
- Python API - Complete API docs
- Agents - QA agent and multi-agent research
- MCP Server - Model Context Protocol integration
- Benchmarks - Performance Benchmarks
mcp-name: io.github.ggozad/haiku-rag
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haiku_rag-0.17.2.tar.gz.
File metadata
- Download URL: haiku_rag-0.17.2.tar.gz
- Upload date:
- Size: 273.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36af7e08aaa468a704eba468686cb9d6115c328881c0eca3e9c56ce084187d75
|
|
| MD5 |
a3b706c5fcd62dc29f9e9b54a9c7a0b1
|
|
| BLAKE2b-256 |
e4dc5fe196c63b8537d1ff6d670f60d21f205ecb98d904e65b48b8a7f8e2c462
|
File details
Details for the file haiku_rag-0.17.2-py3-none-any.whl.
File metadata
- Download URL: haiku_rag-0.17.2-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b79223c0ba4e18afb00c3d0005a88769d6a8f65a4a21af7cad9e4c4237fa5e43
|
|
| MD5 |
7323bd74dfba88e6e5490145888c1adb
|
|
| BLAKE2b-256 |
6eaf630b8c1998fdd04e8af0821147c006875d18799e65a4c5dac12f8ee8a812
|