haiku.rag 0.7.2__tar.gz → 0.7.3__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.

Files changed (78) hide show
  1. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/PKG-INFO +1 -1
  2. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/pyproject.toml +1 -1
  3. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/embeddings/base.py +1 -1
  4. haiku_rag-0.7.3/src/haiku/rag/embeddings/ollama.py +17 -0
  5. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/embeddings/openai.py +5 -2
  6. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/embeddings/vllm.py +5 -2
  7. haiku_rag-0.7.3/src/haiku/rag/embeddings/voyageai.py +17 -0
  8. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/repositories/chunk.py +1 -7
  9. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_embedder.py +28 -4
  10. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/uv.lock +1 -1
  11. haiku_rag-0.7.2/src/haiku/rag/embeddings/ollama.py +0 -11
  12. haiku_rag-0.7.2/src/haiku/rag/embeddings/voyageai.py +0 -13
  13. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.github/FUNDING.yml +0 -0
  14. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.github/workflows/build-docs.yml +0 -0
  15. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.github/workflows/build-publish.yml +0 -0
  16. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.gitignore +0 -0
  17. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.pre-commit-config.yaml +0 -0
  18. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/.python-version +0 -0
  19. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/LICENSE +0 -0
  20. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/README.md +0 -0
  21. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/benchmarks.md +0 -0
  22. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/cli.md +0 -0
  23. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/configuration.md +0 -0
  24. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/index.md +0 -0
  25. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/installation.md +0 -0
  26. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/mcp.md +0 -0
  27. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/python.md +0 -0
  28. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/docs/server.md +0 -0
  29. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/mkdocs.yml +0 -0
  30. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/__init__.py +0 -0
  31. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/app.py +0 -0
  32. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/chunker.py +0 -0
  33. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/cli.py +0 -0
  34. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/client.py +0 -0
  35. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/config.py +0 -0
  36. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/embeddings/__init__.py +0 -0
  37. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/logging.py +0 -0
  38. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/mcp.py +0 -0
  39. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/migration.py +0 -0
  40. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/monitor.py +0 -0
  41. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/qa/__init__.py +0 -0
  42. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/qa/agent.py +0 -0
  43. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/qa/prompts.py +0 -0
  44. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reader.py +0 -0
  45. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reranking/__init__.py +0 -0
  46. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reranking/base.py +0 -0
  47. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reranking/cohere.py +0 -0
  48. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reranking/mxbai.py +0 -0
  49. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/reranking/vllm.py +0 -0
  50. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/__init__.py +0 -0
  51. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/engine.py +0 -0
  52. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/models/__init__.py +0 -0
  53. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/models/chunk.py +0 -0
  54. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/models/document.py +0 -0
  55. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/repositories/__init__.py +0 -0
  56. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/repositories/document.py +0 -0
  57. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/repositories/settings.py +0 -0
  58. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/store/upgrades/__init__.py +0 -0
  59. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/src/haiku/rag/utils.py +0 -0
  60. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/__init__.py +0 -0
  61. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/conftest.py +0 -0
  62. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/generate_benchmark_db.py +0 -0
  63. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/llm_judge.py +0 -0
  64. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_app.py +0 -0
  65. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_chunk.py +0 -0
  66. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_chunker.py +0 -0
  67. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_cli.py +0 -0
  68. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_client.py +0 -0
  69. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_document.py +0 -0
  70. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_lancedb_connection.py +0 -0
  71. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_monitor.py +0 -0
  72. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_qa.py +0 -0
  73. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_reader.py +0 -0
  74. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_rebuild.py +0 -0
  75. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_reranker.py +0 -0
  76. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_search.py +0 -0
  77. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_settings.py +0 -0
  78. {haiku_rag-0.7.2 → haiku_rag-0.7.3}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiku.rag
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: Retrieval Augmented Generation (RAG) with LanceDB
5
5
  Author-email: Yiorgis Gozadinos <ggozadinos@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "haiku.rag"
3
- version = "0.7.2"
3
+ version = "0.7.3"
4
4
  description = "Retrieval Augmented Generation (RAG) with LanceDB"
5
5
  authors = [{ name = "Yiorgis Gozadinos", email = "ggozadinos@gmail.com" }]
6
6
  license = { text = "MIT" }
@@ -9,7 +9,7 @@ class EmbedderBase:
9
9
  self._model = model
10
10
  self._vector_dim = vector_dim
11
11
 
12
- async def embed(self, text: str) -> list[float]:
12
+ async def embed(self, text: str | list[str]) -> list[float] | list[list[float]]:
13
13
  raise NotImplementedError(
14
14
  "Embedder is an abstract class. Please implement the embed method in a subclass."
15
15
  )
@@ -0,0 +1,17 @@
1
+ from openai import AsyncOpenAI
2
+
3
+ from haiku.rag.config import Config
4
+ from haiku.rag.embeddings.base import EmbedderBase
5
+
6
+
7
+ class Embedder(EmbedderBase):
8
+ async def embed(self, text: str | list[str]) -> list[float] | list[list[float]]:
9
+ client = AsyncOpenAI(base_url=f"{Config.OLLAMA_BASE_URL}/v1", api_key="dummy")
10
+ response = await client.embeddings.create(
11
+ model=self._model,
12
+ input=text,
13
+ )
14
+ if isinstance(text, str):
15
+ return response.data[0].embedding
16
+ else:
17
+ return [item.embedding for item in response.data]
@@ -4,10 +4,13 @@ from haiku.rag.embeddings.base import EmbedderBase
4
4
 
5
5
 
6
6
  class Embedder(EmbedderBase):
7
- async def embed(self, text: str) -> list[float]:
7
+ async def embed(self, text: str | list[str]) -> list[float] | list[list[float]]:
8
8
  client = AsyncOpenAI()
9
9
  response = await client.embeddings.create(
10
10
  model=self._model,
11
11
  input=text,
12
12
  )
13
- return response.data[0].embedding
13
+ if isinstance(text, str):
14
+ return response.data[0].embedding
15
+ else:
16
+ return [item.embedding for item in response.data]
@@ -5,7 +5,7 @@ from haiku.rag.embeddings.base import EmbedderBase
5
5
 
6
6
 
7
7
  class Embedder(EmbedderBase):
8
- async def embed(self, text: str) -> list[float]:
8
+ async def embed(self, text: str | list[str]) -> list[float] | list[list[float]]:
9
9
  client = AsyncOpenAI(
10
10
  base_url=f"{Config.VLLM_EMBEDDINGS_BASE_URL}/v1", api_key="dummy"
11
11
  )
@@ -13,4 +13,7 @@ class Embedder(EmbedderBase):
13
13
  model=self._model,
14
14
  input=text,
15
15
  )
16
- return response.data[0].embedding
16
+ if isinstance(text, str):
17
+ return response.data[0].embedding
18
+ else:
19
+ return [item.embedding for item in response.data]
@@ -0,0 +1,17 @@
1
+ try:
2
+ from voyageai.client import Client # type: ignore
3
+
4
+ from haiku.rag.embeddings.base import EmbedderBase
5
+
6
+ class Embedder(EmbedderBase):
7
+ async def embed(self, text: str | list[str]) -> list[float] | list[list[float]]:
8
+ client = Client()
9
+ if isinstance(text, str):
10
+ res = client.embed([text], model=self._model, output_dtype="float")
11
+ return res.embeddings[0] # type: ignore[return-value]
12
+ else:
13
+ res = client.embed(text, model=self._model, output_dtype="float")
14
+ return res.embeddings # type: ignore[return-value]
15
+
16
+ except ImportError:
17
+ pass
@@ -154,13 +154,7 @@ class ChunkRepository:
154
154
  """Create chunks and embeddings for a document from DoclingDocument."""
155
155
  chunk_texts = await chunker.chunk(document)
156
156
 
157
- # Generate embeddings in parallel for all chunks
158
- embeddings_tasks = []
159
- for chunk_text in chunk_texts:
160
- embeddings_tasks.append(self.embedder.embed(chunk_text))
161
-
162
- # Wait for all embeddings to complete
163
- embeddings = await asyncio.gather(*embeddings_tasks)
157
+ embeddings = await self.embedder.embed(chunk_texts)
164
158
 
165
159
  # Prepare all chunk records for batch insertion
166
160
  chunk_records = []
@@ -28,7 +28,13 @@ async def test_ollama_embedder():
28
28
  "Python is my favorite programming language.",
29
29
  "I love to travel and see new places.",
30
30
  ]
31
- embeddings = [np.array(await embedder.embed(phrase)) for phrase in phrases]
31
+
32
+ # Test batch embedding
33
+ embeddings = await embedder.embed(phrases)
34
+ assert isinstance(embeddings, list)
35
+ assert len(embeddings) == 3
36
+ assert all(isinstance(emb, list) for emb in embeddings)
37
+ embeddings = [np.array(emb) for emb in embeddings]
32
38
 
33
39
  test_phrase = "I am going for a camping trip."
34
40
  test_embedding = await embedder.embed(test_phrase)
@@ -58,7 +64,13 @@ async def test_openai_embedder():
58
64
  "Python is my favorite programming language.",
59
65
  "I love to travel and see new places.",
60
66
  ]
61
- embeddings = [np.array(await embedder.embed(phrase)) for phrase in phrases]
67
+
68
+ # Test batch embedding
69
+ embeddings = await embedder.embed(phrases)
70
+ assert isinstance(embeddings, list)
71
+ assert len(embeddings) == 3
72
+ assert all(isinstance(emb, list) for emb in embeddings)
73
+ embeddings = [np.array(emb) for emb in embeddings]
62
74
 
63
75
  test_phrase = "I am going for a camping trip."
64
76
  test_embedding = await embedder.embed(test_phrase)
@@ -91,7 +103,13 @@ async def test_voyageai_embedder():
91
103
  "Python is my favorite programming language.",
92
104
  "I love to travel and see new places.",
93
105
  ]
94
- embeddings = [np.array(await embedder.embed(phrase)) for phrase in phrases]
106
+
107
+ # Test batch embedding
108
+ embeddings = await embedder.embed(phrases)
109
+ assert isinstance(embeddings, list)
110
+ assert len(embeddings) == 3
111
+ assert all(isinstance(emb, list) for emb in embeddings)
112
+ embeddings = [np.array(emb) for emb in embeddings]
95
113
 
96
114
  test_phrase = "I am going for a camping trip."
97
115
  test_embedding = await embedder.embed(test_phrase)
@@ -126,7 +144,13 @@ async def test_vllm_embedder():
126
144
  "Python is my favorite programming language.",
127
145
  "I love to travel and see new places.",
128
146
  ]
129
- embeddings = [np.array(await embedder.embed(phrase)) for phrase in phrases]
147
+
148
+ # Test batch embedding
149
+ embeddings = await embedder.embed(phrases)
150
+ assert isinstance(embeddings, list)
151
+ assert len(embeddings) == 3
152
+ assert all(isinstance(emb, list) for emb in embeddings)
153
+ embeddings = [np.array(emb) for emb in embeddings]
130
154
 
131
155
  test_phrase = "I am going for a camping trip."
132
156
  test_embedding = await embedder.embed(test_phrase)
@@ -951,7 +951,7 @@ wheels = [
951
951
 
952
952
  [[package]]
953
953
  name = "haiku-rag"
954
- version = "0.7.2"
954
+ version = "0.7.3"
955
955
  source = { editable = "." }
956
956
  dependencies = [
957
957
  { name = "docling" },
@@ -1,11 +0,0 @@
1
- from ollama import AsyncClient
2
-
3
- from haiku.rag.config import Config
4
- from haiku.rag.embeddings.base import EmbedderBase
5
-
6
-
7
- class Embedder(EmbedderBase):
8
- async def embed(self, text: str) -> list[float]:
9
- client = AsyncClient(host=Config.OLLAMA_BASE_URL)
10
- res = await client.embeddings(model=self._model, prompt=text)
11
- return list(res["embedding"])
@@ -1,13 +0,0 @@
1
- try:
2
- from voyageai.client import Client # type: ignore
3
-
4
- from haiku.rag.embeddings.base import EmbedderBase
5
-
6
- class Embedder(EmbedderBase):
7
- async def embed(self, text: str) -> list[float]:
8
- client = Client()
9
- res = client.embed([text], model=self._model, output_dtype="float")
10
- return res.embeddings[0] # type: ignore[return-value]
11
-
12
- except ImportError:
13
- pass
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes