haiku.rag 0.9.2__py3-none-any.whl → 0.14.0__py3-none-any.whl

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.
Files changed (53) hide show
  1. README.md +205 -0
  2. haiku_rag-0.14.0.dist-info/METADATA +227 -0
  3. haiku_rag-0.14.0.dist-info/RECORD +6 -0
  4. haiku/rag/__init__.py +0 -0
  5. haiku/rag/app.py +0 -267
  6. haiku/rag/chunker.py +0 -51
  7. haiku/rag/cli.py +0 -359
  8. haiku/rag/client.py +0 -565
  9. haiku/rag/config.py +0 -77
  10. haiku/rag/embeddings/__init__.py +0 -35
  11. haiku/rag/embeddings/base.py +0 -15
  12. haiku/rag/embeddings/ollama.py +0 -17
  13. haiku/rag/embeddings/openai.py +0 -16
  14. haiku/rag/embeddings/vllm.py +0 -19
  15. haiku/rag/embeddings/voyageai.py +0 -17
  16. haiku/rag/logging.py +0 -56
  17. haiku/rag/mcp.py +0 -144
  18. haiku/rag/migration.py +0 -316
  19. haiku/rag/monitor.py +0 -73
  20. haiku/rag/qa/__init__.py +0 -15
  21. haiku/rag/qa/agent.py +0 -89
  22. haiku/rag/qa/prompts.py +0 -60
  23. haiku/rag/reader.py +0 -115
  24. haiku/rag/reranking/__init__.py +0 -34
  25. haiku/rag/reranking/base.py +0 -13
  26. haiku/rag/reranking/cohere.py +0 -34
  27. haiku/rag/reranking/mxbai.py +0 -28
  28. haiku/rag/reranking/vllm.py +0 -44
  29. haiku/rag/research/__init__.py +0 -37
  30. haiku/rag/research/base.py +0 -130
  31. haiku/rag/research/dependencies.py +0 -45
  32. haiku/rag/research/evaluation_agent.py +0 -42
  33. haiku/rag/research/orchestrator.py +0 -300
  34. haiku/rag/research/presearch_agent.py +0 -34
  35. haiku/rag/research/prompts.py +0 -129
  36. haiku/rag/research/search_agent.py +0 -65
  37. haiku/rag/research/synthesis_agent.py +0 -40
  38. haiku/rag/store/__init__.py +0 -4
  39. haiku/rag/store/engine.py +0 -230
  40. haiku/rag/store/models/__init__.py +0 -4
  41. haiku/rag/store/models/chunk.py +0 -15
  42. haiku/rag/store/models/document.py +0 -16
  43. haiku/rag/store/repositories/__init__.py +0 -9
  44. haiku/rag/store/repositories/chunk.py +0 -399
  45. haiku/rag/store/repositories/document.py +0 -234
  46. haiku/rag/store/repositories/settings.py +0 -148
  47. haiku/rag/store/upgrades/__init__.py +0 -1
  48. haiku/rag/utils.py +0 -162
  49. haiku_rag-0.9.2.dist-info/METADATA +0 -131
  50. haiku_rag-0.9.2.dist-info/RECORD +0 -50
  51. {haiku_rag-0.9.2.dist-info → haiku_rag-0.14.0.dist-info}/WHEEL +0 -0
  52. {haiku_rag-0.9.2.dist-info → haiku_rag-0.14.0.dist-info}/entry_points.txt +0 -0
  53. {haiku_rag-0.9.2.dist-info → haiku_rag-0.14.0.dist-info}/licenses/LICENSE +0 -0
README.md ADDED
@@ -0,0 +1,205 @@
1
+ # Haiku RAG
2
+
3
+ Retrieval-Augmented Generation (RAG) library built on LanceDB.
4
+
5
+ `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.
6
+
7
+ > **Note**: Configuration now uses YAML files instead of environment variables. If you're upgrading from an older version, run `haiku-rag init-config --from-env` to migrate your `.env` file to `haiku.rag.yaml`. See [Configuration](https://ggozad.github.io/haiku.rag/configuration/) for details.
8
+
9
+ ## Features
10
+
11
+ - **Local LanceDB**: No external servers required, supports also LanceDB cloud storage, S3, Google Cloud & Azure
12
+ - **Multiple embedding providers**: Ollama, VoyageAI, OpenAI, vLLM
13
+ - **Multiple QA providers**: Any provider/model supported by Pydantic AI
14
+ - **Research graph (multi‑agent)**: Plan → Search → Evaluate → Synthesize with agentic AI
15
+ - **Native hybrid search**: Vector + full-text search with native LanceDB RRF reranking
16
+ - **Reranking**: Default search result reranking with MixedBread AI, Cohere, Zero Entropy, or vLLM
17
+ - **Question answering**: Built-in QA agents on your documents
18
+ - **File monitoring**: Auto-index files when run as server
19
+ - **40+ file formats**: PDF, DOCX, HTML, Markdown, code files, URLs
20
+ - **MCP server**: Expose as tools for AI assistants
21
+ - **A2A agent**: Conversational agent with context and multi-turn dialogue
22
+ - **CLI & Python API**: Use from command line or Python
23
+
24
+ ## Installation
25
+
26
+ **Python 3.12 or newer required**
27
+
28
+ ### Full Package (Recommended)
29
+
30
+ ```bash
31
+ uv pip install haiku.rag
32
+ ```
33
+
34
+ Includes all features: document processing, all embedding providers, rerankers, and A2A agent support.
35
+
36
+ ### Slim Package (Minimal Dependencies)
37
+
38
+ ```bash
39
+ uv pip install haiku.rag-slim
40
+ ```
41
+
42
+ Install only the extras you need. See the [Installation](https://ggozad.github.io/haiku.rag/installation/) documentation for available options
43
+
44
+ ## Quick Start
45
+
46
+ ```bash
47
+ # Add documents
48
+ haiku-rag add "Your content here"
49
+ haiku-rag add "Your content here" --meta author=alice --meta topic=notes
50
+ haiku-rag add-src document.pdf --meta source=manual
51
+
52
+ # Search
53
+ haiku-rag search "query"
54
+
55
+ # Search with filters
56
+ haiku-rag search "query" --filter "uri LIKE '%.pdf' AND title LIKE '%paper%'"
57
+
58
+ # Ask questions
59
+ haiku-rag ask "Who is the author of haiku.rag?"
60
+
61
+ # Ask questions with citations
62
+ haiku-rag ask "Who is the author of haiku.rag?" --cite
63
+
64
+ # Deep QA (multi-agent question decomposition)
65
+ haiku-rag ask "Who is the author of haiku.rag?" --deep --cite
66
+
67
+ # Deep QA with verbose output
68
+ haiku-rag ask "Who is the author of haiku.rag?" --deep --verbose
69
+
70
+ # Multi‑agent research (iterative plan/search/evaluate)
71
+ haiku-rag research \
72
+ "What are the main drivers and trends of global temperature anomalies since 1990?" \
73
+ --max-iterations 2 \
74
+ --confidence-threshold 0.8 \
75
+ --max-concurrency 3 \
76
+ --verbose
77
+
78
+ # Rebuild database (re-chunk and re-embed all documents)
79
+ haiku-rag rebuild
80
+
81
+ # Start server with file monitoring
82
+ haiku-rag serve --monitor
83
+ ```
84
+
85
+ To customize settings, create a `haiku.rag.yaml` config file (see [Configuration](https://ggozad.github.io/haiku.rag/configuration/)).
86
+
87
+ ## Python Usage
88
+
89
+ ```python
90
+ from haiku.rag.client import HaikuRAG
91
+ from haiku.rag.research import (
92
+ PlanNode,
93
+ ResearchContext,
94
+ ResearchDeps,
95
+ ResearchState,
96
+ build_research_graph,
97
+ stream_research_graph,
98
+ )
99
+
100
+ async with HaikuRAG("database.lancedb") as client:
101
+ # Add document
102
+ doc = await client.create_document("Your content")
103
+
104
+ # Search (reranking enabled by default)
105
+ results = await client.search("query")
106
+ for chunk, score in results:
107
+ print(f"{score:.3f}: {chunk.content}")
108
+
109
+ # Ask questions
110
+ answer = await client.ask("Who is the author of haiku.rag?")
111
+ print(answer)
112
+
113
+ # Ask questions with citations
114
+ answer = await client.ask("Who is the author of haiku.rag?", cite=True)
115
+ print(answer)
116
+
117
+ # Multi‑agent research pipeline (Plan → Search → Evaluate → Synthesize)
118
+ graph = build_research_graph()
119
+ question = (
120
+ "What are the main drivers and trends of global temperature "
121
+ "anomalies since 1990?"
122
+ )
123
+ state = ResearchState(
124
+ context=ResearchContext(original_question=question),
125
+ max_iterations=2,
126
+ confidence_threshold=0.8,
127
+ max_concurrency=2,
128
+ )
129
+ deps = ResearchDeps(client=client)
130
+
131
+ # Blocking run (final result only)
132
+ result = await graph.run(
133
+ PlanNode(provider="openai", model="gpt-4o-mini"),
134
+ state=state,
135
+ deps=deps,
136
+ )
137
+ print(result.output.title)
138
+
139
+ # Streaming progress (log/report/error events)
140
+ async for event in stream_research_graph(
141
+ graph,
142
+ PlanNode(provider="openai", model="gpt-4o-mini"),
143
+ state,
144
+ deps,
145
+ ):
146
+ if event.type == "log":
147
+ iteration = event.state.iterations if event.state else state.iterations
148
+ print(f"[{iteration}] {event.message}")
149
+ elif event.type == "report":
150
+ print("\nResearch complete!\n")
151
+ print(event.report.title)
152
+ print(event.report.executive_summary)
153
+ ```
154
+
155
+ ## MCP Server
156
+
157
+ Use with AI assistants like Claude Desktop:
158
+
159
+ ```bash
160
+ haiku-rag serve --stdio
161
+ ```
162
+
163
+ Provides tools for document management and search directly in your AI assistant.
164
+
165
+ ## A2A Agent
166
+
167
+ Run as a conversational agent with the Agent-to-Agent protocol:
168
+
169
+ ```bash
170
+ # Start the A2A server
171
+ haiku-rag serve --a2a
172
+
173
+ # Connect with the interactive client (in another terminal)
174
+ haiku-rag a2aclient
175
+ ```
176
+
177
+ The A2A agent provides:
178
+
179
+ - Multi-turn dialogue with context
180
+ - Intelligent multi-search for complex questions
181
+ - Source citations with titles and URIs
182
+ - Full document retrieval on request
183
+
184
+ ## Examples
185
+
186
+ See the [examples directory](examples/) for working examples:
187
+
188
+ - **[Interactive Research Assistant](examples/ag-ui-research/)** - Full-stack research assistant with Pydantic AI and AG-UI featuring human-in-the-loop approval and real-time state synchronization
189
+ - **[Docker Setup](examples/docker/)** - Complete Docker deployment with file monitoring, MCP server, and A2A agent
190
+ - **[A2A Security](examples/a2a-security/)** - Authentication examples (API key, OAuth2, GitHub)
191
+
192
+ ## Documentation
193
+
194
+ Full documentation at: https://ggozad.github.io/haiku.rag/
195
+
196
+ - [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
197
+ - [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - YAML configuration
198
+ - [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
199
+ - [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
200
+ - [Agents](https://ggozad.github.io/haiku.rag/agents/) - QA agent and multi-agent research
201
+ - [MCP Server](https://ggozad.github.io/haiku.rag/mcp/) - Model Context Protocol integration
202
+ - [A2A Agent](https://ggozad.github.io/haiku.rag/a2a/) - Agent-to-Agent protocol support
203
+ - [Benchmarks](https://ggozad.github.io/haiku.rag/benchmarks/) - Performance Benchmarks
204
+
205
+ mcp-name: io.github.ggozad/haiku-rag
@@ -0,0 +1,227 @@
1
+ Metadata-Version: 2.4
2
+ Name: haiku.rag
3
+ Version: 0.14.0
4
+ Summary: Agentic Retrieval Augmented Generation (RAG) with LanceDB
5
+ Author-email: Yiorgis Gozadinos <ggozadinos@gmail.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: RAG,lancedb,mcp,ml,vector-database
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.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.12
20
+ Requires-Dist: haiku-rag-slim[a2a,cohere,docling,mxbai,voyageai,zeroentropy]
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Haiku RAG
24
+
25
+ Retrieval-Augmented Generation (RAG) library built on LanceDB.
26
+
27
+ `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.
28
+
29
+ > **Note**: Configuration now uses YAML files instead of environment variables. If you're upgrading from an older version, run `haiku-rag init-config --from-env` to migrate your `.env` file to `haiku.rag.yaml`. See [Configuration](https://ggozad.github.io/haiku.rag/configuration/) for details.
30
+
31
+ ## Features
32
+
33
+ - **Local LanceDB**: No external servers required, supports also LanceDB cloud storage, S3, Google Cloud & Azure
34
+ - **Multiple embedding providers**: Ollama, VoyageAI, OpenAI, vLLM
35
+ - **Multiple QA providers**: Any provider/model supported by Pydantic AI
36
+ - **Research graph (multi‑agent)**: Plan → Search → Evaluate → Synthesize with agentic AI
37
+ - **Native hybrid search**: Vector + full-text search with native LanceDB RRF reranking
38
+ - **Reranking**: Default search result reranking with MixedBread AI, Cohere, Zero Entropy, or vLLM
39
+ - **Question answering**: Built-in QA agents on your documents
40
+ - **File monitoring**: Auto-index files when run as server
41
+ - **40+ file formats**: PDF, DOCX, HTML, Markdown, code files, URLs
42
+ - **MCP server**: Expose as tools for AI assistants
43
+ - **A2A agent**: Conversational agent with context and multi-turn dialogue
44
+ - **CLI & Python API**: Use from command line or Python
45
+
46
+ ## Installation
47
+
48
+ **Python 3.12 or newer required**
49
+
50
+ ### Full Package (Recommended)
51
+
52
+ ```bash
53
+ uv pip install haiku.rag
54
+ ```
55
+
56
+ Includes all features: document processing, all embedding providers, rerankers, and A2A agent support.
57
+
58
+ ### Slim Package (Minimal Dependencies)
59
+
60
+ ```bash
61
+ uv pip install haiku.rag-slim
62
+ ```
63
+
64
+ Install only the extras you need. See the [Installation](https://ggozad.github.io/haiku.rag/installation/) documentation for available options
65
+
66
+ ## Quick Start
67
+
68
+ ```bash
69
+ # Add documents
70
+ haiku-rag add "Your content here"
71
+ haiku-rag add "Your content here" --meta author=alice --meta topic=notes
72
+ haiku-rag add-src document.pdf --meta source=manual
73
+
74
+ # Search
75
+ haiku-rag search "query"
76
+
77
+ # Search with filters
78
+ haiku-rag search "query" --filter "uri LIKE '%.pdf' AND title LIKE '%paper%'"
79
+
80
+ # Ask questions
81
+ haiku-rag ask "Who is the author of haiku.rag?"
82
+
83
+ # Ask questions with citations
84
+ haiku-rag ask "Who is the author of haiku.rag?" --cite
85
+
86
+ # Deep QA (multi-agent question decomposition)
87
+ haiku-rag ask "Who is the author of haiku.rag?" --deep --cite
88
+
89
+ # Deep QA with verbose output
90
+ haiku-rag ask "Who is the author of haiku.rag?" --deep --verbose
91
+
92
+ # Multi‑agent research (iterative plan/search/evaluate)
93
+ haiku-rag research \
94
+ "What are the main drivers and trends of global temperature anomalies since 1990?" \
95
+ --max-iterations 2 \
96
+ --confidence-threshold 0.8 \
97
+ --max-concurrency 3 \
98
+ --verbose
99
+
100
+ # Rebuild database (re-chunk and re-embed all documents)
101
+ haiku-rag rebuild
102
+
103
+ # Start server with file monitoring
104
+ haiku-rag serve --monitor
105
+ ```
106
+
107
+ To customize settings, create a `haiku.rag.yaml` config file (see [Configuration](https://ggozad.github.io/haiku.rag/configuration/)).
108
+
109
+ ## Python Usage
110
+
111
+ ```python
112
+ from haiku.rag.client import HaikuRAG
113
+ from haiku.rag.research import (
114
+ PlanNode,
115
+ ResearchContext,
116
+ ResearchDeps,
117
+ ResearchState,
118
+ build_research_graph,
119
+ stream_research_graph,
120
+ )
121
+
122
+ async with HaikuRAG("database.lancedb") as client:
123
+ # Add document
124
+ doc = await client.create_document("Your content")
125
+
126
+ # Search (reranking enabled by default)
127
+ results = await client.search("query")
128
+ for chunk, score in results:
129
+ print(f"{score:.3f}: {chunk.content}")
130
+
131
+ # Ask questions
132
+ answer = await client.ask("Who is the author of haiku.rag?")
133
+ print(answer)
134
+
135
+ # Ask questions with citations
136
+ answer = await client.ask("Who is the author of haiku.rag?", cite=True)
137
+ print(answer)
138
+
139
+ # Multi‑agent research pipeline (Plan → Search → Evaluate → Synthesize)
140
+ graph = build_research_graph()
141
+ question = (
142
+ "What are the main drivers and trends of global temperature "
143
+ "anomalies since 1990?"
144
+ )
145
+ state = ResearchState(
146
+ context=ResearchContext(original_question=question),
147
+ max_iterations=2,
148
+ confidence_threshold=0.8,
149
+ max_concurrency=2,
150
+ )
151
+ deps = ResearchDeps(client=client)
152
+
153
+ # Blocking run (final result only)
154
+ result = await graph.run(
155
+ PlanNode(provider="openai", model="gpt-4o-mini"),
156
+ state=state,
157
+ deps=deps,
158
+ )
159
+ print(result.output.title)
160
+
161
+ # Streaming progress (log/report/error events)
162
+ async for event in stream_research_graph(
163
+ graph,
164
+ PlanNode(provider="openai", model="gpt-4o-mini"),
165
+ state,
166
+ deps,
167
+ ):
168
+ if event.type == "log":
169
+ iteration = event.state.iterations if event.state else state.iterations
170
+ print(f"[{iteration}] {event.message}")
171
+ elif event.type == "report":
172
+ print("\nResearch complete!\n")
173
+ print(event.report.title)
174
+ print(event.report.executive_summary)
175
+ ```
176
+
177
+ ## MCP Server
178
+
179
+ Use with AI assistants like Claude Desktop:
180
+
181
+ ```bash
182
+ haiku-rag serve --stdio
183
+ ```
184
+
185
+ Provides tools for document management and search directly in your AI assistant.
186
+
187
+ ## A2A Agent
188
+
189
+ Run as a conversational agent with the Agent-to-Agent protocol:
190
+
191
+ ```bash
192
+ # Start the A2A server
193
+ haiku-rag serve --a2a
194
+
195
+ # Connect with the interactive client (in another terminal)
196
+ haiku-rag a2aclient
197
+ ```
198
+
199
+ The A2A agent provides:
200
+
201
+ - Multi-turn dialogue with context
202
+ - Intelligent multi-search for complex questions
203
+ - Source citations with titles and URIs
204
+ - Full document retrieval on request
205
+
206
+ ## Examples
207
+
208
+ See the [examples directory](examples/) for working examples:
209
+
210
+ - **[Interactive Research Assistant](examples/ag-ui-research/)** - Full-stack research assistant with Pydantic AI and AG-UI featuring human-in-the-loop approval and real-time state synchronization
211
+ - **[Docker Setup](examples/docker/)** - Complete Docker deployment with file monitoring, MCP server, and A2A agent
212
+ - **[A2A Security](examples/a2a-security/)** - Authentication examples (API key, OAuth2, GitHub)
213
+
214
+ ## Documentation
215
+
216
+ Full documentation at: https://ggozad.github.io/haiku.rag/
217
+
218
+ - [Installation](https://ggozad.github.io/haiku.rag/installation/) - Provider setup
219
+ - [Configuration](https://ggozad.github.io/haiku.rag/configuration/) - YAML configuration
220
+ - [CLI](https://ggozad.github.io/haiku.rag/cli/) - Command reference
221
+ - [Python API](https://ggozad.github.io/haiku.rag/python/) - Complete API docs
222
+ - [Agents](https://ggozad.github.io/haiku.rag/agents/) - QA agent and multi-agent research
223
+ - [MCP Server](https://ggozad.github.io/haiku.rag/mcp/) - Model Context Protocol integration
224
+ - [A2A Agent](https://ggozad.github.io/haiku.rag/a2a/) - Agent-to-Agent protocol support
225
+ - [Benchmarks](https://ggozad.github.io/haiku.rag/benchmarks/) - Performance Benchmarks
226
+
227
+ mcp-name: io.github.ggozad/haiku-rag
@@ -0,0 +1,6 @@
1
+ README.md,sha256=N8nk6cs6JkWHAmVz3ci7lTiLr6Xq_UqifWGivZnuPJU,7216
2
+ haiku_rag-0.14.0.dist-info/METADATA,sha256=I3H0hBrGIgDwtIvFe9tnu2-PeLESLlhEHVrgmrKCnr4,8085
3
+ haiku_rag-0.14.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ haiku_rag-0.14.0.dist-info/entry_points.txt,sha256=G1U3nAkNd5YDYd4v0tuYFbriz0i-JheCsFuT9kIoGCI,48
5
+ haiku_rag-0.14.0.dist-info/licenses/LICENSE,sha256=eXZrWjSk9PwYFNK9yUczl3oPl95Z4V9UXH7bPN46iPo,1065
6
+ haiku_rag-0.14.0.dist-info/RECORD,,
haiku/rag/__init__.py DELETED
File without changes