haiku.rag 0.1.0__tar.gz → 0.3.0__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.1.0 → haiku_rag-0.3.0}/.pre-commit-config.yaml +10 -0
- haiku_rag-0.3.0/BENCHMARKS.md +13 -0
- haiku_rag-0.3.0/PKG-INFO +112 -0
- haiku_rag-0.3.0/README.md +75 -0
- haiku_rag-0.3.0/docs/cli.md +83 -0
- haiku_rag-0.3.0/docs/configuration.md +104 -0
- haiku_rag-0.3.0/docs/index.md +59 -0
- haiku_rag-0.3.0/docs/installation.md +31 -0
- haiku_rag-0.3.0/docs/mcp.md +33 -0
- haiku_rag-0.3.0/docs/python.md +109 -0
- haiku_rag-0.3.0/docs/server.md +41 -0
- haiku_rag-0.3.0/mkdocs.yml +77 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/pyproject.toml +5 -1
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/app.py +35 -15
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/cli.py +16 -1
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/client.py +16 -2
- haiku_rag-0.3.0/src/haiku/rag/config.py +51 -0
- haiku_rag-0.3.0/src/haiku/rag/embeddings/__init__.py +36 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/embeddings/ollama.py +1 -1
- haiku_rag-0.3.0/src/haiku/rag/embeddings/openai.py +20 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/embeddings/voyageai.py +1 -1
- haiku_rag-0.3.0/src/haiku/rag/logging.py +24 -0
- haiku_rag-0.3.0/src/haiku/rag/monitor.py +73 -0
- haiku_rag-0.3.0/src/haiku/rag/qa/__init__.py +26 -0
- haiku_rag-0.3.0/src/haiku/rag/qa/base.py +41 -0
- haiku_rag-0.3.0/src/haiku/rag/qa/ollama.py +67 -0
- haiku_rag-0.3.0/src/haiku/rag/qa/openai.py +101 -0
- haiku_rag-0.3.0/src/haiku/rag/qa/prompts.py +7 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/models/chunk.py +3 -1
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/repositories/chunk.py +33 -13
- haiku_rag-0.3.0/tests/__init__.py +0 -0
- haiku_rag-0.3.0/tests/generate_benchmark_db.py +129 -0
- haiku_rag-0.3.0/tests/llm_judge.py +68 -0
- haiku_rag-0.3.0/tests/test_app.py +208 -0
- haiku_rag-0.3.0/tests/test_cli.py +129 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/test_client.py +2 -2
- haiku_rag-0.3.0/tests/test_embedder.py +128 -0
- haiku_rag-0.3.0/tests/test_monitor.py +99 -0
- haiku_rag-0.3.0/tests/test_qa.py +62 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/test_search.py +30 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/uv.lock +377 -2
- haiku_rag-0.1.0/.claude/settings.local.json +0 -15
- haiku_rag-0.1.0/CLAUDE.md +0 -35
- haiku_rag-0.1.0/PKG-INFO +0 -195
- haiku_rag-0.1.0/README.md +0 -161
- haiku_rag-0.1.0/src/haiku/rag/config.py +0 -28
- haiku_rag-0.1.0/src/haiku/rag/embeddings/__init__.py +0 -24
- haiku_rag-0.1.0/tests/test_embedder.py +0 -48
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/.github/FUNDING.yml +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/.github/workflows/build-docs.yml +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/.github/workflows/build-publish.yml +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/.gitignore +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/.python-version +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/LICENSE +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/__init__.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/chunker.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/embeddings/base.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/mcp.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/reader.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/__init__.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/engine.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/models/__init__.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/models/document.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/repositories/__init__.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/repositories/base.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/store/repositories/document.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/src/haiku/rag/utils.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/conftest.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/test_chunk.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/test_chunker.py +0 -0
- {haiku_rag-0.1.0 → haiku_rag-0.3.0}/tests/test_document.py +0 -0
|
@@ -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.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: haiku.rag
|
|
3
|
+
Version: 0.3.0
|
|
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: openai
|
|
33
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
34
|
+
Provides-Extra: voyageai
|
|
35
|
+
Requires-Dist: voyageai>=0.3.2; extra == 'voyageai'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# Haiku SQLite RAG
|
|
39
|
+
|
|
40
|
+
Retrieval-Augmented Generation (RAG) library on SQLite.
|
|
41
|
+
|
|
42
|
+
`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.
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- **Local SQLite**: No external servers required
|
|
47
|
+
- **Multiple embedding providers**: Ollama, VoyageAI, OpenAI
|
|
48
|
+
- **Hybrid search**: Vector + full-text search with Reciprocal Rank Fusion
|
|
49
|
+
- **Question answering**: Built-in QA agents on your documents
|
|
50
|
+
- **File monitoring**: Auto-index files when run as server
|
|
51
|
+
- **40+ file formats**: PDF, DOCX, HTML, Markdown, audio, URLs
|
|
52
|
+
- **MCP server**: Expose as tools for AI assistants
|
|
53
|
+
- **CLI & Python API**: Use from command line or Python
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Install
|
|
59
|
+
uv pip install haiku.rag
|
|
60
|
+
|
|
61
|
+
# Add documents
|
|
62
|
+
haiku-rag add "Your content here"
|
|
63
|
+
haiku-rag add-src document.pdf
|
|
64
|
+
|
|
65
|
+
# Search
|
|
66
|
+
haiku-rag search "query"
|
|
67
|
+
|
|
68
|
+
# Ask questions
|
|
69
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
70
|
+
|
|
71
|
+
# Start server with file monitoring
|
|
72
|
+
export MONITOR_DIRECTORIES="/path/to/docs"
|
|
73
|
+
haiku-rag serve
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Python Usage
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from haiku.rag.client import HaikuRAG
|
|
80
|
+
|
|
81
|
+
async with HaikuRAG("database.db") as client:
|
|
82
|
+
# Add document
|
|
83
|
+
doc = await client.create_document("Your content")
|
|
84
|
+
|
|
85
|
+
# Search
|
|
86
|
+
results = await client.search("query")
|
|
87
|
+
for chunk, score in results:
|
|
88
|
+
print(f"{score:.3f}: {chunk.content}")
|
|
89
|
+
|
|
90
|
+
# Ask questions
|
|
91
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
92
|
+
print(answer)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## MCP Server
|
|
96
|
+
|
|
97
|
+
Use with AI assistants like Claude Desktop:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
haiku-rag serve --stdio
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Provides tools for document management and search directly in your AI assistant.
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
Full documentation at: https://ggozad.github.io/haiku.rag/
|
|
108
|
+
|
|
109
|
+
- [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
|
|
110
|
+
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - Environment variables
|
|
111
|
+
- [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
|
|
112
|
+
- [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
- **Hybrid search**: Vector + full-text search with Reciprocal Rank Fusion
|
|
12
|
+
- **Question answering**: Built-in QA agents on your documents
|
|
13
|
+
- **File monitoring**: Auto-index files when run as server
|
|
14
|
+
- **40+ file formats**: PDF, DOCX, HTML, Markdown, audio, URLs
|
|
15
|
+
- **MCP server**: Expose as tools for AI assistants
|
|
16
|
+
- **CLI & Python API**: Use from command line or Python
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install
|
|
22
|
+
uv pip install haiku.rag
|
|
23
|
+
|
|
24
|
+
# Add documents
|
|
25
|
+
haiku-rag add "Your content here"
|
|
26
|
+
haiku-rag add-src document.pdf
|
|
27
|
+
|
|
28
|
+
# Search
|
|
29
|
+
haiku-rag search "query"
|
|
30
|
+
|
|
31
|
+
# Ask questions
|
|
32
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
33
|
+
|
|
34
|
+
# Start server with file monitoring
|
|
35
|
+
export MONITOR_DIRECTORIES="/path/to/docs"
|
|
36
|
+
haiku-rag serve
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Python Usage
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from haiku.rag.client import HaikuRAG
|
|
43
|
+
|
|
44
|
+
async with HaikuRAG("database.db") as client:
|
|
45
|
+
# Add document
|
|
46
|
+
doc = await client.create_document("Your content")
|
|
47
|
+
|
|
48
|
+
# Search
|
|
49
|
+
results = await client.search("query")
|
|
50
|
+
for chunk, score in results:
|
|
51
|
+
print(f"{score:.3f}: {chunk.content}")
|
|
52
|
+
|
|
53
|
+
# Ask questions
|
|
54
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
55
|
+
print(answer)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## MCP Server
|
|
59
|
+
|
|
60
|
+
Use with AI assistants like Claude Desktop:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
haiku-rag serve --stdio
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Provides tools for document management and search directly in your AI assistant.
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
Full documentation at: https://ggozad.github.io/haiku.rag/
|
|
71
|
+
|
|
72
|
+
- [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
|
|
73
|
+
- [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - Environment variables
|
|
74
|
+
- [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
|
|
75
|
+
- [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
## Search
|
|
39
|
+
|
|
40
|
+
Basic search:
|
|
41
|
+
```bash
|
|
42
|
+
haiku-rag search "machine learning"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
With options:
|
|
46
|
+
```bash
|
|
47
|
+
haiku-rag search "python programming" --limit 10 --k 100
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Question Answering
|
|
51
|
+
|
|
52
|
+
Ask questions about your documents:
|
|
53
|
+
```bash
|
|
54
|
+
haiku-rag ask "Who is the author of haiku.rag?"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The QA agent will search your documents for relevant information and provide a comprehensive answer.
|
|
58
|
+
|
|
59
|
+
## Server
|
|
60
|
+
|
|
61
|
+
Start the MCP server:
|
|
62
|
+
```bash
|
|
63
|
+
# HTTP transport (default)
|
|
64
|
+
haiku-rag serve
|
|
65
|
+
|
|
66
|
+
# stdio transport
|
|
67
|
+
haiku-rag serve --stdio
|
|
68
|
+
|
|
69
|
+
# SSE transport
|
|
70
|
+
haiku-rag serve --sse
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Options
|
|
74
|
+
|
|
75
|
+
All commands support:
|
|
76
|
+
- `--db` - Specify custom database path
|
|
77
|
+
- `-h` - Show help for specific command
|
|
78
|
+
|
|
79
|
+
Example:
|
|
80
|
+
```bash
|
|
81
|
+
haiku-rag list --db /path/to/custom.db
|
|
82
|
+
haiku-rag add -h
|
|
83
|
+
```
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
## Other Settings
|
|
88
|
+
|
|
89
|
+
### Database and Storage
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Default data directory (where SQLite database is stored)
|
|
93
|
+
DEFAULT_DATA_DIR="/path/to/data"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Document Processing
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Chunk size for document processing
|
|
100
|
+
CHUNK_SIZE=256
|
|
101
|
+
|
|
102
|
+
# Chunk overlap for better context
|
|
103
|
+
CHUNK_OVERLAP=32
|
|
104
|
+
```
|
|
@@ -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 or OpenAI.
|
|
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,31 @@
|
|
|
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
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- Python 3.10+
|
|
30
|
+
- SQLite 3.38+
|
|
31
|
+
- 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
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Python API
|
|
2
|
+
|
|
3
|
+
Use `haiku.rag` directly in your Python applications.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from haiku.rag.client import HaikuRAG
|
|
10
|
+
|
|
11
|
+
# Use as async context manager (recommended)
|
|
12
|
+
async with HaikuRAG("path/to/database.db") as client:
|
|
13
|
+
# Your code here
|
|
14
|
+
pass
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Document Management
|
|
18
|
+
|
|
19
|
+
### Creating Documents
|
|
20
|
+
|
|
21
|
+
From text:
|
|
22
|
+
```python
|
|
23
|
+
doc = await client.create_document(
|
|
24
|
+
content="Your document content here",
|
|
25
|
+
uri="doc://example",
|
|
26
|
+
metadata={"source": "manual", "topic": "example"}
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
From file:
|
|
31
|
+
```python
|
|
32
|
+
doc = await client.create_document_from_source("path/to/document.pdf")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
From URL:
|
|
36
|
+
```python
|
|
37
|
+
doc = await client.create_document_from_source("https://example.com/article.html")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Retrieving Documents
|
|
41
|
+
|
|
42
|
+
By ID:
|
|
43
|
+
```python
|
|
44
|
+
doc = await client.get_document_by_id(1)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
By URI:
|
|
48
|
+
```python
|
|
49
|
+
doc = await client.get_document_by_uri("file:///path/to/document.pdf")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
List all documents:
|
|
53
|
+
```python
|
|
54
|
+
docs = await client.list_documents(limit=10, offset=0)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Updating Documents
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
doc.content = "Updated content"
|
|
61
|
+
await client.update_document(doc)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Deleting Documents
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
await client.delete_document(doc.id)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Searching Documents
|
|
71
|
+
|
|
72
|
+
Basic search:
|
|
73
|
+
```python
|
|
74
|
+
results = await client.search("machine learning algorithms", limit=5)
|
|
75
|
+
for chunk, score in results:
|
|
76
|
+
print(f"Score: {score:.3f}")
|
|
77
|
+
print(f"Content: {chunk.content}")
|
|
78
|
+
print(f"Document ID: {chunk.document_id}")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
With options:
|
|
82
|
+
```python
|
|
83
|
+
results = await client.search(
|
|
84
|
+
query="machine learning",
|
|
85
|
+
limit=5, # Maximum results to return
|
|
86
|
+
k=60 # RRF parameter for reciprocal rank fusion
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# Process results
|
|
90
|
+
for chunk, relevance_score in results:
|
|
91
|
+
print(f"Relevance: {relevance_score:.3f}")
|
|
92
|
+
print(f"Content: {chunk.content}")
|
|
93
|
+
print(f"From document: {chunk.document_id}")
|
|
94
|
+
print(f"Document URI: {chunk.document_uri}")
|
|
95
|
+
print(f"Document metadata: {chunk.document_meta}")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Question Answering
|
|
99
|
+
|
|
100
|
+
Ask questions about your documents:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
answer = await client.ask("Who is the author of haiku.rag?")
|
|
104
|
+
print(answer)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The QA agent will search your documents for relevant information and use the configured LLM to generate a comprehensive answer.
|
|
108
|
+
|
|
109
|
+
The QA provider and model can be configured via environment variables (see [Configuration](configuration.md)).
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Server Mode
|
|
2
|
+
|
|
3
|
+
The server provides automatic file monitoring and MCP functionality.
|
|
4
|
+
|
|
5
|
+
## Starting the Server
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
haiku-rag serve
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Transport options:
|
|
12
|
+
- `--http` (default) - Streamable HTTP transport
|
|
13
|
+
- `--stdio` - Standard input/output transport
|
|
14
|
+
- `--sse` - Server-sent events transport
|
|
15
|
+
|
|
16
|
+
## File Monitoring
|
|
17
|
+
|
|
18
|
+
Set `MONITOR_DIRECTORIES` environment variable to enable automatic file monitoring:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
export MONITOR_DIRECTORIES="/path/to/documents"
|
|
22
|
+
haiku-rag serve
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Monitoring Features
|
|
26
|
+
|
|
27
|
+
- **Startup**: Scans all monitored directories and adds new files
|
|
28
|
+
- **File Added/Modified**: Automatically parses and updates documents
|
|
29
|
+
- **File Deleted**: Removes corresponding documents from database
|
|
30
|
+
|
|
31
|
+
### Supported Formats
|
|
32
|
+
|
|
33
|
+
The server can parse 40+ file formats including:
|
|
34
|
+
- PDF documents
|
|
35
|
+
- Microsoft Office (DOCX, XLSX, PPTX)
|
|
36
|
+
- HTML and Markdown
|
|
37
|
+
- Plain text files
|
|
38
|
+
- Audio files
|
|
39
|
+
- And more...
|
|
40
|
+
|
|
41
|
+
URLs are also supported for web content.
|