haiku.rag 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of haiku.rag might be problematic. Click here for more details.
- haiku_rag-0.3.1/.github/workflows/build-docs.yml +28 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/.pre-commit-config.yaml +10 -0
- haiku_rag-0.3.1/BENCHMARKS.md +13 -0
- haiku_rag-0.3.1/PKG-INFO +118 -0
- haiku_rag-0.3.1/README.md +79 -0
- haiku_rag-0.3.1/docs/cli.md +100 -0
- haiku_rag-0.3.1/docs/configuration.md +120 -0
- haiku_rag-0.3.1/docs/index.md +59 -0
- haiku_rag-0.3.1/docs/installation.md +37 -0
- haiku_rag-0.3.1/docs/mcp.md +33 -0
- haiku_rag-0.3.1/docs/python.md +116 -0
- haiku_rag-0.3.1/docs/server.md +41 -0
- haiku_rag-0.3.1/mkdocs.yml +77 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/pyproject.toml +4 -1
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/app.py +62 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/cli.py +36 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/client.py +39 -1
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/config.py +14 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/monitor.py +0 -1
- haiku_rag-0.3.1/src/haiku/rag/qa/__init__.py +39 -0
- haiku_rag-0.3.1/src/haiku/rag/qa/anthropic.py +112 -0
- haiku_rag-0.3.1/src/haiku/rag/qa/base.py +41 -0
- haiku_rag-0.3.1/src/haiku/rag/qa/ollama.py +67 -0
- haiku_rag-0.3.1/src/haiku/rag/qa/openai.py +101 -0
- haiku_rag-0.3.1/src/haiku/rag/qa/prompts.py +7 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/models/chunk.py +3 -1
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/repositories/chunk.py +49 -13
- haiku_rag-0.3.1/tests/__init__.py +0 -0
- haiku_rag-0.3.1/tests/generate_benchmark_db.py +129 -0
- haiku_rag-0.3.1/tests/llm_judge.py +68 -0
- haiku_rag-0.3.1/tests/test_app.py +208 -0
- haiku_rag-0.3.1/tests/test_cli.py +129 -0
- haiku_rag-0.3.1/tests/test_qa.py +94 -0
- haiku_rag-0.3.1/tests/test_rebuild.py +52 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_search.py +30 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/uv.lock +295 -2
- haiku_rag-0.2.0/PKG-INFO +0 -230
- haiku_rag-0.2.0/README.md +0 -193
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/.github/FUNDING.yml +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/.github/workflows/build-publish.yml +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/.gitignore +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/.python-version +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/LICENSE +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/__init__.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/chunker.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/embeddings/__init__.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/embeddings/base.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/embeddings/ollama.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/embeddings/openai.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/embeddings/voyageai.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/logging.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/mcp.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/reader.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/__init__.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/engine.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/models/__init__.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/models/document.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/repositories/__init__.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/repositories/base.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/store/repositories/document.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/src/haiku/rag/utils.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/conftest.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_chunk.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_chunker.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_client.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_document.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_embedder.py +0 -0
- {haiku_rag-0.2.0 → haiku_rag-0.3.1}/tests/test_monitor.py +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: build-docs
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- name: Configure Git Credentials
|
|
14
|
+
run: |
|
|
15
|
+
git config user.name github-actions[bot]
|
|
16
|
+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: 3.x
|
|
20
|
+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
|
21
|
+
- uses: actions/cache@v4
|
|
22
|
+
with:
|
|
23
|
+
key: mkdocs-material-${{ env.cache_id }}
|
|
24
|
+
path: .cache
|
|
25
|
+
restore-keys: |
|
|
26
|
+
mkdocs-material-
|
|
27
|
+
- run: pip install mkdocs-material
|
|
28
|
+
- run: mkdocs gh-deploy --force
|
|
@@ -20,3 +20,13 @@ repos:
|
|
|
20
20
|
rev: v1.1.399
|
|
21
21
|
hooks:
|
|
22
22
|
- id: pyright
|
|
23
|
+
|
|
24
|
+
- repo: https://github.com/RodrigoGonzalez/check-mkdocs
|
|
25
|
+
rev: v1.2.0
|
|
26
|
+
hooks:
|
|
27
|
+
- id: check-mkdocs
|
|
28
|
+
name: check-mkdocs
|
|
29
|
+
args: ["--config", "mkdocs.yml"] # Optional, mkdocs.yml is the default
|
|
30
|
+
# If you have additional plugins or libraries that are not included in
|
|
31
|
+
# check-mkdocs, add them here
|
|
32
|
+
additional_dependencies: ["mkdocs-material"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# `haiku.rag` benchmarks
|
|
2
|
+
|
|
3
|
+
We use [repliqa](https://huggingface.co/datasets/ServiceNow/repliqa) for the evaluation of `haiku.rag`
|
|
4
|
+
|
|
5
|
+
* Recall
|
|
6
|
+
|
|
7
|
+
We load the `News Stories` from `repliqa_3` which is 1035 documents, using `tests/generate_benchmark_db.py`, using the `mxbai-embed-large` Ollama embeddings.
|
|
8
|
+
|
|
9
|
+
Subsequently, we run a search over the `question` for each row of the dataset and check whether we match the document that answers the question. The recall obtained is ~0.75 for matching in the top result, raising to ~0.75 for the top 3 results.
|
|
10
|
+
|
|
11
|
+
* Question/Answer evaluation
|
|
12
|
+
|
|
13
|
+
We use the `News Stories` from `repliqa_3` using the `mxbai-embed-large` Ollama embeddings, with a QA agent also using Ollama with the `qwen3` model (8b). For each story we ask the `question` and use an LLM judge (also `qwen3`) to evaluate whether the answer is correct or not. Thus we obtain accuracy of ~0.54.
|
haiku_rag-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: haiku.rag
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Retrieval Augmented Generation (RAG) with SQLite
|
|
5
|
+
Author-email: Yiorgis Gozadinos <ggozadinos@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: RAG,mcp,ml,sqlite,sqlite-vec
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: fastmcp>=2.8.1
|
|
22
|
+
Requires-Dist: httpx>=0.28.1
|
|
23
|
+
Requires-Dist: markitdown[audio-transcription,docx,pdf,pptx,xlsx]>=0.1.2
|
|
24
|
+
Requires-Dist: ollama>=0.5.1
|
|
25
|
+
Requires-Dist: pydantic>=2.11.7
|
|
26
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
27
|
+
Requires-Dist: rich>=14.0.0
|
|
28
|
+
Requires-Dist: sqlite-vec>=0.1.6
|
|
29
|
+
Requires-Dist: tiktoken>=0.9.0
|
|
30
|
+
Requires-Dist: typer>=0.16.0
|
|
31
|
+
Requires-Dist: watchfiles>=1.1.0
|
|
32
|
+
Provides-Extra: anthropic
|
|
33
|
+
Requires-Dist: anthropic>=0.56.0; extra == 'anthropic'
|
|
34
|
+
Provides-Extra: openai
|
|
35
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
36
|
+
Provides-Extra: voyageai
|
|
37
|
+
Requires-Dist: voyageai>=0.3.2; extra == 'voyageai'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Haiku SQLite RAG
|
|
41
|
+
|
|
42
|
+
Retrieval-Augmented Generation (RAG) library on SQLite.
|
|
43
|
+
|
|
44
|
+
`haiku.rag` is a Retrieval-Augmented Generation (RAG) library built to work on SQLite alone without the need for external vector databases. It uses [sqlite-vec](https://github.com/asg017/sqlite-vec) for storing the embeddings and performs semantic (vector) search as well as full-text search combined through Reciprocal Rank Fusion. Both open-source (Ollama) as well as commercial (OpenAI, VoyageAI) embedding providers are supported.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **Local SQLite**: No external servers required
|
|
49
|
+
- **Multiple embedding providers**: Ollama, VoyageAI, OpenAI
|
|
50
|
+
- **Multiple QA providers**: Ollama, OpenAI, Anthropic
|
|
51
|
+
- **Hybrid search**: Vector + full-text search with Reciprocal Rank Fusion
|
|
52
|
+
- **Question answering**: Built-in QA agents on your documents
|
|
53
|
+
- **File monitoring**: Auto-index files when run as server
|
|
54
|
+
- **40+ file formats**: PDF, DOCX, HTML, Markdown, audio, URLs
|
|
55
|
+
- **MCP server**: Expose as tools for AI assistants
|
|
56
|
+
- **CLI & Python API**: Use from command line or Python
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Install
|
|
62
|
+
uv pip install haiku.rag
|
|
63
|
+
|
|
64
|
+
# Add documents
|
|
65
|
+
haiku-rag add "Your content here"
|
|
66
|
+
haiku-rag add-src document.pdf
|
|
67
|
+
|
|
68
|
+
# Search
|
|
69
|
+
haiku-rag search "query"
|
|
70
|
+
|
|
71
|
+
# Ask questions
|
|
72
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
73
|
+
|
|
74
|
+
# Rebuild database (re-chunk and re-embed all documents)
|
|
75
|
+
haiku-rag rebuild
|
|
76
|
+
|
|
77
|
+
# Start server with file monitoring
|
|
78
|
+
export MONITOR_DIRECTORIES="/path/to/docs"
|
|
79
|
+
haiku-rag serve
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Python Usage
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from haiku.rag.client import HaikuRAG
|
|
86
|
+
|
|
87
|
+
async with HaikuRAG("database.db") as client:
|
|
88
|
+
# Add document
|
|
89
|
+
doc = await client.create_document("Your content")
|
|
90
|
+
|
|
91
|
+
# Search
|
|
92
|
+
results = await client.search("query")
|
|
93
|
+
for chunk, score in results:
|
|
94
|
+
print(f"{score:.3f}: {chunk.content}")
|
|
95
|
+
|
|
96
|
+
# Ask questions
|
|
97
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
98
|
+
print(answer)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## MCP Server
|
|
102
|
+
|
|
103
|
+
Use with AI assistants like Claude Desktop:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
haiku-rag serve --stdio
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Provides tools for document management and search directly in your AI assistant.
|
|
110
|
+
|
|
111
|
+
## Documentation
|
|
112
|
+
|
|
113
|
+
Full documentation at: https://ggozad.github.io/haiku.rag/
|
|
114
|
+
|
|
115
|
+
- [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
|
|
116
|
+
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - Environment variables
|
|
117
|
+
- [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
|
|
118
|
+
- [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Haiku SQLite RAG
|
|
2
|
+
|
|
3
|
+
Retrieval-Augmented Generation (RAG) library on SQLite.
|
|
4
|
+
|
|
5
|
+
`haiku.rag` is a Retrieval-Augmented Generation (RAG) library built to work on SQLite alone without the need for external vector databases. It uses [sqlite-vec](https://github.com/asg017/sqlite-vec) for storing the embeddings and performs semantic (vector) search as well as full-text search combined through Reciprocal Rank Fusion. Both open-source (Ollama) as well as commercial (OpenAI, VoyageAI) embedding providers are supported.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Local SQLite**: No external servers required
|
|
10
|
+
- **Multiple embedding providers**: Ollama, VoyageAI, OpenAI
|
|
11
|
+
- **Multiple QA providers**: Ollama, OpenAI, Anthropic
|
|
12
|
+
- **Hybrid search**: Vector + full-text search with Reciprocal Rank Fusion
|
|
13
|
+
- **Question answering**: Built-in QA agents on your documents
|
|
14
|
+
- **File monitoring**: Auto-index files when run as server
|
|
15
|
+
- **40+ file formats**: PDF, DOCX, HTML, Markdown, audio, URLs
|
|
16
|
+
- **MCP server**: Expose as tools for AI assistants
|
|
17
|
+
- **CLI & Python API**: Use from command line or Python
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install
|
|
23
|
+
uv pip install haiku.rag
|
|
24
|
+
|
|
25
|
+
# Add documents
|
|
26
|
+
haiku-rag add "Your content here"
|
|
27
|
+
haiku-rag add-src document.pdf
|
|
28
|
+
|
|
29
|
+
# Search
|
|
30
|
+
haiku-rag search "query"
|
|
31
|
+
|
|
32
|
+
# Ask questions
|
|
33
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
34
|
+
|
|
35
|
+
# Rebuild database (re-chunk and re-embed all documents)
|
|
36
|
+
haiku-rag rebuild
|
|
37
|
+
|
|
38
|
+
# Start server with file monitoring
|
|
39
|
+
export MONITOR_DIRECTORIES="/path/to/docs"
|
|
40
|
+
haiku-rag serve
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Python Usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from haiku.rag.client import HaikuRAG
|
|
47
|
+
|
|
48
|
+
async with HaikuRAG("database.db") as client:
|
|
49
|
+
# Add document
|
|
50
|
+
doc = await client.create_document("Your content")
|
|
51
|
+
|
|
52
|
+
# Search
|
|
53
|
+
results = await client.search("query")
|
|
54
|
+
for chunk, score in results:
|
|
55
|
+
print(f"{score:.3f}: {chunk.content}")
|
|
56
|
+
|
|
57
|
+
# Ask questions
|
|
58
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
59
|
+
print(answer)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## MCP Server
|
|
63
|
+
|
|
64
|
+
Use with AI assistants like Claude Desktop:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
haiku-rag serve --stdio
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Provides tools for document management and search directly in your AI assistant.
|
|
71
|
+
|
|
72
|
+
## Documentation
|
|
73
|
+
|
|
74
|
+
Full documentation at: https://ggozad.github.io/haiku.rag/
|
|
75
|
+
|
|
76
|
+
- [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
|
|
77
|
+
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - Environment variables
|
|
78
|
+
- [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
|
|
79
|
+
- [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Command Line Interface
|
|
2
|
+
|
|
3
|
+
The `haiku-rag` CLI provides complete document management functionality.
|
|
4
|
+
|
|
5
|
+
## Document Management
|
|
6
|
+
|
|
7
|
+
### List Documents
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
haiku-rag list
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Add Documents
|
|
14
|
+
|
|
15
|
+
From text:
|
|
16
|
+
```bash
|
|
17
|
+
haiku-rag add "Your document content here"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
From file or URL:
|
|
21
|
+
```bash
|
|
22
|
+
haiku-rag add-src /path/to/document.pdf
|
|
23
|
+
haiku-rag add-src https://example.com/article.html
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Get Document
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
haiku-rag get 1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Delete Document
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
haiku-rag delete 1
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Rebuild Database
|
|
39
|
+
|
|
40
|
+
Rebuild the database by deleting all chunks & embeddings and re-indexing all documents:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
haiku-rag rebuild
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use this when you want to change things like the embedding model or chunk size for example.
|
|
47
|
+
|
|
48
|
+
## Search
|
|
49
|
+
|
|
50
|
+
Basic search:
|
|
51
|
+
```bash
|
|
52
|
+
haiku-rag search "machine learning"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
With options:
|
|
56
|
+
```bash
|
|
57
|
+
haiku-rag search "python programming" --limit 10 --k 100
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Question Answering
|
|
61
|
+
|
|
62
|
+
Ask questions about your documents:
|
|
63
|
+
```bash
|
|
64
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The QA agent will search your documents for relevant information and provide a comprehensive answer.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
View current configuration settings:
|
|
72
|
+
```bash
|
|
73
|
+
haiku-rag settings
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Server
|
|
77
|
+
|
|
78
|
+
Start the MCP server:
|
|
79
|
+
```bash
|
|
80
|
+
# HTTP transport (default)
|
|
81
|
+
haiku-rag serve
|
|
82
|
+
|
|
83
|
+
# stdio transport
|
|
84
|
+
haiku-rag serve --stdio
|
|
85
|
+
|
|
86
|
+
# SSE transport
|
|
87
|
+
haiku-rag serve --sse
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
All commands support:
|
|
93
|
+
- `--db` - Specify custom database path
|
|
94
|
+
- `-h` - Show help for specific command
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
```bash
|
|
98
|
+
haiku-rag list --db /path/to/custom.db
|
|
99
|
+
haiku-rag add -h
|
|
100
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
Configuration is done through the use of environment variables.
|
|
4
|
+
|
|
5
|
+
## File Monitoring
|
|
6
|
+
|
|
7
|
+
Set directories to monitor for automatic indexing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Monitor single directory
|
|
11
|
+
MONITOR_DIRECTORIES="/path/to/documents"
|
|
12
|
+
|
|
13
|
+
# Monitor multiple directories
|
|
14
|
+
MONITOR_DIRECTORIES="/path/to/documents,/another_path/to/documents"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Embedding Providers
|
|
18
|
+
|
|
19
|
+
If you use Ollama, you can use any pulled model that supports embeddings.
|
|
20
|
+
|
|
21
|
+
### Ollama (Default)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
EMBEDDINGS_PROVIDER="ollama"
|
|
25
|
+
EMBEDDINGS_MODEL="mxbai-embed-large"
|
|
26
|
+
EMBEDDINGS_VECTOR_DIM=1024
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### VoyageAI
|
|
30
|
+
If you want to use VoyageAI embeddings you will need to install `haiku.rag` with the VoyageAI extras,
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv pip install haiku.rag --extra voyageai
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
EMBEDDINGS_PROVIDER="voyageai"
|
|
38
|
+
EMBEDDINGS_MODEL="voyage-3.5"
|
|
39
|
+
EMBEDDINGS_VECTOR_DIM=1024
|
|
40
|
+
VOYAGE_API_KEY="your-api-key"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### OpenAI
|
|
44
|
+
If you want to use OpenAI embeddings you will need to install `haiku.rag` with the VoyageAI extras,
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv pip install haiku.rag --extra openai
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
and set environment variables.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
EMBEDDINGS_PROVIDER="openai"
|
|
54
|
+
EMBEDDINGS_MODEL="text-embedding-3-small" # or text-embedding-3-large
|
|
55
|
+
EMBEDDINGS_VECTOR_DIM=1536
|
|
56
|
+
OPENAI_API_KEY="your-api-key"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Question Answering Providers
|
|
60
|
+
|
|
61
|
+
Configure which LLM provider to use for question answering.
|
|
62
|
+
|
|
63
|
+
### Ollama (Default)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
QA_PROVIDER="ollama"
|
|
67
|
+
QA_MODEL="qwen3"
|
|
68
|
+
OLLAMA_BASE_URL="http://localhost:11434"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### OpenAI
|
|
72
|
+
|
|
73
|
+
For OpenAI QA, you need to install haiku.rag with OpenAI extras:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv pip install haiku.rag --extra openai
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then configure:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
QA_PROVIDER="openai"
|
|
83
|
+
QA_MODEL="gpt-4o-mini" # or gpt-4, gpt-3.5-turbo, etc.
|
|
84
|
+
OPENAI_API_KEY="your-api-key"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Anthropic
|
|
88
|
+
|
|
89
|
+
For Anthropic QA, you need to install haiku.rag with Anthropic extras:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
uv pip install haiku.rag --extra anthropic
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then configure:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
QA_PROVIDER="anthropic"
|
|
99
|
+
QA_MODEL="claude-3-5-haiku-20241022" # or claude-3-5-sonnet-20241022, etc.
|
|
100
|
+
ANTHROPIC_API_KEY="your-api-key"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Other Settings
|
|
104
|
+
|
|
105
|
+
### Database and Storage
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Default data directory (where SQLite database is stored)
|
|
109
|
+
DEFAULT_DATA_DIR="/path/to/data"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Document Processing
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Chunk size for document processing
|
|
116
|
+
CHUNK_SIZE=256
|
|
117
|
+
|
|
118
|
+
# Chunk overlap for better context
|
|
119
|
+
CHUNK_OVERLAP=32
|
|
120
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# haiku.rag
|
|
2
|
+
|
|
3
|
+
`haiku.rag` is a Retrieval-Augmented Generation (RAG) library built to work on SQLite alone without the need for external vector databases. It uses [sqlite-vec](https://github.com/asg017/sqlite-vec) for storing the embeddings and performs semantic (vector) search as well as full-text search combined through Reciprocal Rank Fusion. Both open-source (Ollama) as well as commercial (OpenAI, VoyageAI) embedding providers are supported.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Local SQLite**: No need to run additional servers
|
|
9
|
+
- **Support for various embedding providers**: Ollama, VoyageAI, OpenAI or add your own
|
|
10
|
+
- **Hybrid Search**: Vector search using `sqlite-vec` combined with full-text search `FTS5`, using Reciprocal Rank Fusion
|
|
11
|
+
- **Question Answering**: Built-in QA agents using Ollama, OpenAI, or Anthropic.
|
|
12
|
+
- **File monitoring**: Automatically index files when run as a server
|
|
13
|
+
- **Extended file format support**: Parse 40+ file formats including PDF, DOCX, HTML, Markdown, audio and more. Or add a URL!
|
|
14
|
+
- **MCP server**: Exposes functionality as MCP tools
|
|
15
|
+
- **CLI commands**: Access all functionality from your terminal
|
|
16
|
+
- **Python client**: Call `haiku.rag` from your own python applications
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
Install haiku.rag:
|
|
21
|
+
```bash
|
|
22
|
+
uv pip install haiku.rag
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Use from Python:
|
|
26
|
+
```python
|
|
27
|
+
from haiku.rag.client import HaikuRAG
|
|
28
|
+
|
|
29
|
+
async with HaikuRAG("database.db") as client:
|
|
30
|
+
# Add a document
|
|
31
|
+
doc = await client.create_document("Your content here")
|
|
32
|
+
|
|
33
|
+
# Search documents
|
|
34
|
+
results = await client.search("query")
|
|
35
|
+
|
|
36
|
+
# Ask questions
|
|
37
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or use the CLI:
|
|
41
|
+
```bash
|
|
42
|
+
haiku-rag add "Your document content"
|
|
43
|
+
haiku-rag search "query"
|
|
44
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
- [Installation](installation.md) - Install haiku.rag with different providers
|
|
50
|
+
- [Configuration](configuration.md) - Environment variables and settings
|
|
51
|
+
- [CLI](cli.md) - Command line interface usage
|
|
52
|
+
- [Question Answering](qa.md) - QA agents and natural language queries
|
|
53
|
+
- [Server](server.md) - File monitoring and server mode
|
|
54
|
+
- [MCP](mcp.md) - Model Context Protocol integration
|
|
55
|
+
- [Python](python.md) - Python API reference
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
This project is licensed under the [MIT License](https://raw.githubusercontent.com/ggozad/haiku.rag/main/LICENSE).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Basic Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
uv pip install haiku.rag
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
By default, Ollama (with the `mxbai-embed-large` model) is used for embeddings.
|
|
10
|
+
|
|
11
|
+
## Provider-Specific Installation
|
|
12
|
+
|
|
13
|
+
For other embedding providers, install with extras:
|
|
14
|
+
|
|
15
|
+
### VoyageAI
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv pip install haiku.rag --extra voyageai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### OpenAI
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv pip install haiku.rag --extra openai
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Anthropic
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv pip install haiku.rag --extra anthropic
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Requirements
|
|
34
|
+
|
|
35
|
+
- Python 3.10+
|
|
36
|
+
- SQLite 3.38+
|
|
37
|
+
- Ollama (for default embeddings)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Model Context Protocol (MCP)
|
|
2
|
+
|
|
3
|
+
The MCP server exposes `haiku.rag` as MCP tools for compatible MCP clients.
|
|
4
|
+
|
|
5
|
+
## Available Tools
|
|
6
|
+
|
|
7
|
+
### Document Management
|
|
8
|
+
|
|
9
|
+
- `add_document_from_file` - Add documents from local file paths
|
|
10
|
+
- `add_document_from_url` - Add documents from URLs
|
|
11
|
+
- `add_document_from_text` - Add documents from raw text content
|
|
12
|
+
- `get_document` - Retrieve specific documents by ID
|
|
13
|
+
- `list_documents` - List all documents with pagination
|
|
14
|
+
- `delete_document` - Delete documents by ID
|
|
15
|
+
|
|
16
|
+
### Search
|
|
17
|
+
|
|
18
|
+
- `search_documents` - Search documents using hybrid search (vector + full-text)
|
|
19
|
+
|
|
20
|
+
## Starting MCP Server
|
|
21
|
+
|
|
22
|
+
The MCP server starts automatically with the serve command and supports `Streamable HTTP`, `stdio` and `SSE` transports:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Default HTTP transport
|
|
26
|
+
haiku-rag serve
|
|
27
|
+
|
|
28
|
+
# stdio transport (for Claude Desktop)
|
|
29
|
+
haiku-rag serve --stdio
|
|
30
|
+
|
|
31
|
+
# SSE transport
|
|
32
|
+
haiku-rag serve --sse
|
|
33
|
+
```
|