haiku.rag 0.7.1__py3-none-any.whl → 0.7.2__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.

Potentially problematic release.


This version of haiku.rag might be problematic. Click here for more details.

haiku/rag/config.py CHANGED
@@ -33,6 +33,9 @@ class AppConfig(BaseModel):
33
33
  CONTEXT_CHUNK_RADIUS: int = 0
34
34
 
35
35
  OLLAMA_BASE_URL: str = "http://localhost:11434"
36
+ VLLM_EMBEDDINGS_BASE_URL: str = ""
37
+ VLLM_RERANK_BASE_URL: str = ""
38
+ VLLM_QA_BASE_URL: str = ""
36
39
 
37
40
  # Provider keys
38
41
  VOYAGE_API_KEY: str = ""
@@ -0,0 +1,16 @@
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[float]:
9
+ client = AsyncOpenAI(
10
+ base_url=f"{Config.VLLM_EMBEDDINGS_BASE_URL}/v1", api_key="dummy"
11
+ )
12
+ response = await client.embeddings.create(
13
+ model=self._model,
14
+ input=text,
15
+ )
16
+ return response.data[0].embedding
haiku/rag/qa/agent.py CHANGED
@@ -2,6 +2,7 @@ from pydantic import BaseModel, Field
2
2
  from pydantic_ai import Agent, RunContext
3
3
  from pydantic_ai.models.openai import OpenAIChatModel
4
4
  from pydantic_ai.providers.ollama import OllamaProvider
5
+ from pydantic_ai.providers.openai import OpenAIProvider
5
6
 
6
7
  from haiku.rag.client import HaikuRAG
7
8
  from haiku.rag.config import Config
@@ -65,6 +66,13 @@ class QuestionAnswerAgent:
65
66
  model_name=model,
66
67
  provider=OllamaProvider(base_url=f"{Config.OLLAMA_BASE_URL}/v1"),
67
68
  )
69
+ elif provider == "vllm":
70
+ return OpenAIChatModel(
71
+ model_name=model,
72
+ provider=OpenAIProvider(
73
+ base_url=f"{Config.VLLM_QA_BASE_URL}/v1", api_key="none"
74
+ ),
75
+ )
68
76
  else:
69
77
  # For all other providers, use the provider:model format
70
78
  return f"{provider}:{model}"
@@ -0,0 +1,44 @@
1
+ import httpx
2
+
3
+ from haiku.rag.config import Config
4
+ from haiku.rag.reranking.base import RerankerBase
5
+ from haiku.rag.store.models.chunk import Chunk
6
+
7
+
8
+ class VLLMReranker(RerankerBase):
9
+ def __init__(self, model: str):
10
+ self._model = model
11
+ self._base_url = Config.VLLM_RERANK_BASE_URL
12
+
13
+ async def rerank(
14
+ self, query: str, chunks: list[Chunk], top_n: int = 10
15
+ ) -> list[tuple[Chunk, float]]:
16
+ if not chunks:
17
+ return []
18
+
19
+ # Prepare documents for reranking
20
+ documents = [chunk.content for chunk in chunks]
21
+
22
+ async with httpx.AsyncClient() as client:
23
+ response = await client.post(
24
+ f"{self._base_url}/v1/rerank",
25
+ json={"model": self._model, "query": query, "documents": documents},
26
+ headers={
27
+ "accept": "application/json",
28
+ "Content-Type": "application/json",
29
+ },
30
+ )
31
+ response.raise_for_status()
32
+
33
+ result = response.json()
34
+
35
+ # Extract scores and pair with chunks
36
+ scored_chunks = []
37
+ for item in result.get("results", []):
38
+ index = item["index"]
39
+ score = item["relevance_score"]
40
+ scored_chunks.append((chunks[index], score))
41
+
42
+ # Sort by score (descending) and return top_n
43
+ scored_chunks.sort(key=lambda x: x[1], reverse=True)
44
+ return scored_chunks[:top_n]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiku.rag
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Retrieval Augmented Generation (RAG) with LanceDB
5
5
  Author-email: Yiorgis Gozadinos <ggozadinos@gmail.com>
6
6
  License: MIT
@@ -47,10 +47,10 @@ Retrieval-Augmented Generation (RAG) library built on LanceDB.
47
47
  ## Features
48
48
 
49
49
  - **Local LanceDB**: No external servers required, supports also LanceDB cloud storage, S3, Google Cloud & Azure
50
- - **Multiple embedding providers**: Ollama, VoyageAI, OpenAI
50
+ - **Multiple embedding providers**: Ollama, VoyageAI, OpenAI, vLLM
51
51
  - **Multiple QA providers**: Any provider/model supported by Pydantic AI
52
52
  - **Native hybrid search**: Vector + full-text search with native LanceDB RRF reranking
53
- - **Reranking**: Default search result reranking with MixedBread AI or Cohere
53
+ - **Reranking**: Default search result reranking with MixedBread AI, Cohere, or vLLM
54
54
  - **Question answering**: Built-in QA agents on your documents
55
55
  - **File monitoring**: Auto-index files when run as server
56
56
  - **40+ file formats**: PDF, DOCX, HTML, Markdown, code files, URLs
@@ -3,7 +3,7 @@ haiku/rag/app.py,sha256=GmuZxH7BMutWt8Mdu0RSateRBaKiqXh7Z9tV7cZX6n0,7655
3
3
  haiku/rag/chunker.py,sha256=PVe6ysv8UlacUd4Zb3_8RFWIaWDXnzBAy2VDJ4TaUsE,1555
4
4
  haiku/rag/cli.py,sha256=UY9Vh5RsIxSCV14eQbNOiwToKmbFAvqTOAnxjieaYBs,6399
5
5
  haiku/rag/client.py,sha256=N4zkWjE9Rsw9YgPvNo83xptHUQR2ognfOnjkoV_w6hc,20999
6
- haiku/rag/config.py,sha256=9Mv0QJ3c6VF1oVRSXJlSsG234dCd_sKnJO-ybMaTpDQ,1690
6
+ haiku/rag/config.py,sha256=3H41da9BU1R1y2JJHD0cOSErX_VSM1UXA7M2JSOxFXE,1795
7
7
  haiku/rag/logging.py,sha256=DOQi9QMpQRl8h17Vu4nQh8HxpHdeIu29n8-HZaT3SRQ,786
8
8
  haiku/rag/mcp.py,sha256=bR9Y-Nz-hvjiql20Y0KE0hwNGwyjmPGX8K9d-qmXptY,4683
9
9
  haiku/rag/migration.py,sha256=gWxQwiKo0YulRhogYz4K8N98kHN9LQXIx9FeTmT24v4,10915
@@ -14,14 +14,16 @@ haiku/rag/embeddings/__init__.py,sha256=n7aHW3BxHlpGxU4ze4YYDOsljzFpEep8dwVE2n45
14
14
  haiku/rag/embeddings/base.py,sha256=NTQvuzbZPu0LBo5wAu3qGyJ4xXUaRAt1fjBO0ygWn_Y,465
15
15
  haiku/rag/embeddings/ollama.py,sha256=y6-lp0XpbnyIjoOEdtSzMdEVkU5glOwnWQ1FkpUZnpI,370
16
16
  haiku/rag/embeddings/openai.py,sha256=iA-DewCOSip8PLU_RhEJHFHBle4DtmCCIGNfGs58Wvk,357
17
+ haiku/rag/embeddings/vllm.py,sha256=ymNDmpIvDWmkmce5j-TRc_QnJR4qwZCpnYA0tP3ab5o,480
17
18
  haiku/rag/embeddings/voyageai.py,sha256=0hiRTIqu-bpl-4OaCtMHvWfPdgbrzhnfZJowSV8pLRA,415
18
19
  haiku/rag/qa/__init__.py,sha256=Sl7Kzrg9CuBOcMF01wc1NtQhUNWjJI0MhIHfCWrb8V4,434
19
- haiku/rag/qa/agent.py,sha256=gZ12vLUSHHCMl0HyPoLlPDbhUWoyEUydXG7u8lG1eqg,2602
20
+ haiku/rag/qa/agent.py,sha256=15-jMuF08U0uxGdqgQysKMZLr8BUWssI76PtyQ2Ngd8,2912
20
21
  haiku/rag/qa/prompts.py,sha256=xdT4cyrOrAK9UDgVqyev1wHF49jD57Bh40gx2sH4NPI,3341
21
22
  haiku/rag/reranking/__init__.py,sha256=IRXHs4qPu6VbGJQpzSwhgtVWWumURH_vEoVFE-extlo,894
22
23
  haiku/rag/reranking/base.py,sha256=LM9yUSSJ414UgBZhFTgxGprlRqzfTe4I1vgjricz2JY,405
23
24
  haiku/rag/reranking/cohere.py,sha256=1iTdiaa8vvb6oHVB2qpWzUOVkyfUcimVSZp6Qr4aq4c,1049
24
25
  haiku/rag/reranking/mxbai.py,sha256=46sVTsTIkzIX9THgM3u8HaEmgY7evvEyB-N54JTHvK8,867
26
+ haiku/rag/reranking/vllm.py,sha256=xVGH9ss-ISWdJ5SKUUHUbTqBo7PIEmA_SQv0ScdJ6XA,1479
25
27
  haiku/rag/store/__init__.py,sha256=hq0W0DAC7ysqhWSP2M2uHX8cbG6kbr-sWHxhq6qQcY0,103
26
28
  haiku/rag/store/engine.py,sha256=XHGo5Xl-dCFdQHrOdMo64xVK5n0k8-LoUl5V-tlA0HI,7131
27
29
  haiku/rag/store/models/__init__.py,sha256=s0E72zneGlowvZrFWaNxHYjOAUjgWdLxzdYsnvNRVlY,88
@@ -32,8 +34,8 @@ haiku/rag/store/repositories/chunk.py,sha256=5S77mGh6pWxPHjaXriJGmvbSOhoNM8tLwyg
32
34
  haiku/rag/store/repositories/document.py,sha256=lP8Lo82KTP-qwXFRpYZ46WjeAdAsHwZ5pJcrXdz4g0U,6988
33
35
  haiku/rag/store/repositories/settings.py,sha256=dqnAvm-98nQrWpLBbf9QghJw673QD80-iqQhRMP5t0c,5025
34
36
  haiku/rag/store/upgrades/__init__.py,sha256=wUiEoSiHTahvuagx93E4FB07v123AhdbOjwUkPusiIg,14
35
- haiku_rag-0.7.1.dist-info/METADATA,sha256=yIz4nATa_b2vDstrCZe9CzV_77Vw74QIhRWqCZCdaes,4597
36
- haiku_rag-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
- haiku_rag-0.7.1.dist-info/entry_points.txt,sha256=G1U3nAkNd5YDYd4v0tuYFbriz0i-JheCsFuT9kIoGCI,48
38
- haiku_rag-0.7.1.dist-info/licenses/LICENSE,sha256=eXZrWjSk9PwYFNK9yUczl3oPl95Z4V9UXH7bPN46iPo,1065
39
- haiku_rag-0.7.1.dist-info/RECORD,,
37
+ haiku_rag-0.7.2.dist-info/METADATA,sha256=CLBIBBUYbvBbtynct-n_q7ZVO6cayLa7YUeFivrwEf4,4610
38
+ haiku_rag-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
+ haiku_rag-0.7.2.dist-info/entry_points.txt,sha256=G1U3nAkNd5YDYd4v0tuYFbriz0i-JheCsFuT9kIoGCI,48
40
+ haiku_rag-0.7.2.dist-info/licenses/LICENSE,sha256=eXZrWjSk9PwYFNK9yUczl3oPl95Z4V9UXH7bPN46iPo,1065
41
+ haiku_rag-0.7.2.dist-info/RECORD,,