Spaces:
Sleeping
Sleeping
Upload src/retriever.py with huggingface_hub
Browse files- src/retriever.py +5 -2
src/retriever.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
Queries ChromaDB with source-aware routing driven by router output.
|
| 4 |
"""
|
| 5 |
|
|
|
|
| 6 |
import chromadb
|
| 7 |
from src.embedder import embed_query
|
| 8 |
|
|
@@ -17,8 +18,9 @@ def retrieve(
|
|
| 17 |
*,
|
| 18 |
top_k: int = 20,
|
| 19 |
client_path: str = "./chroma_db",
|
| 20 |
-
collection_name: str = "
|
| 21 |
) -> list[dict]:
|
|
|
|
| 22 |
"""Retrieve chunks for *query* based on the router's classification.
|
| 23 |
|
| 24 |
Opens a ChromaDB connection, embeds *query*, then dispatches on
|
|
@@ -141,8 +143,9 @@ def retrieve_multi(
|
|
| 141 |
*,
|
| 142 |
top_k: int = 10,
|
| 143 |
client_path: str = "./chroma_db",
|
| 144 |
-
collection_name: str = "
|
| 145 |
) -> list[dict]:
|
|
|
|
| 146 |
"""Multi-query retrieval with Reciprocal Rank Fusion.
|
| 147 |
|
| 148 |
Runs semantic search for each query variant (original + paraphrases),
|
|
|
|
| 3 |
Queries ChromaDB with source-aware routing driven by router output.
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
import chromadb
|
| 8 |
from src.embedder import embed_query
|
| 9 |
|
|
|
|
| 18 |
*,
|
| 19 |
top_k: int = 20,
|
| 20 |
client_path: str = "./chroma_db",
|
| 21 |
+
collection_name: str = "greenmetric_bgem3",
|
| 22 |
) -> list[dict]:
|
| 23 |
+
collection_name = os.getenv("RAG_COLLECTION", collection_name)
|
| 24 |
"""Retrieve chunks for *query* based on the router's classification.
|
| 25 |
|
| 26 |
Opens a ChromaDB connection, embeds *query*, then dispatches on
|
|
|
|
| 143 |
*,
|
| 144 |
top_k: int = 10,
|
| 145 |
client_path: str = "./chroma_db",
|
| 146 |
+
collection_name: str = "greenmetric_bgem3",
|
| 147 |
) -> list[dict]:
|
| 148 |
+
collection_name = os.getenv("RAG_COLLECTION", collection_name)
|
| 149 |
"""Multi-query retrieval with Reciprocal Rank Fusion.
|
| 150 |
|
| 151 |
Runs semantic search for each query variant (original + paraphrases),
|