Spaces:
Sleeping
Sleeping
Upload src/labdaps/retrieval/vector_store.py with huggingface_hub
Browse files
src/labdaps/retrieval/vector_store.py
CHANGED
|
@@ -16,7 +16,7 @@ def build_index(chunks: list[Chunk], embedder: Embedder, rebuild: bool = False)
|
|
| 16 |
if rebuild:
|
| 17 |
try:
|
| 18 |
client.delete_collection(COLLECTION_NAME)
|
| 19 |
-
print(f"[INFO]
|
| 20 |
except Exception:
|
| 21 |
pass
|
| 22 |
|
|
@@ -26,7 +26,7 @@ def build_index(chunks: list[Chunk], embedder: Embedder, rebuild: bool = False)
|
|
| 26 |
)
|
| 27 |
|
| 28 |
if collection.count() > 0 and not rebuild:
|
| 29 |
-
print(f"[INFO]
|
| 30 |
return
|
| 31 |
|
| 32 |
texts = [c.text for c in chunks]
|
|
@@ -47,7 +47,7 @@ def build_index(chunks: list[Chunk], embedder: Embedder, rebuild: bool = False)
|
|
| 47 |
)
|
| 48 |
print(f"[INFO] Indexados chunks {i} a {min(i+batch_size, len(chunks))}/{len(chunks)}")
|
| 49 |
|
| 50 |
-
print(f"[INFO]
|
| 51 |
|
| 52 |
|
| 53 |
def query_store(query_embedding: list[float], top_k: int):
|
|
|
|
| 16 |
if rebuild:
|
| 17 |
try:
|
| 18 |
client.delete_collection(COLLECTION_NAME)
|
| 19 |
+
print(f"[INFO] Coleção '{COLLECTION_NAME}' removida.")
|
| 20 |
except Exception:
|
| 21 |
pass
|
| 22 |
|
|
|
|
| 26 |
)
|
| 27 |
|
| 28 |
if collection.count() > 0 and not rebuild:
|
| 29 |
+
print(f"[INFO] Coleção já contém {collection.count()} chunks. Use --rebuild para re-indexar.")
|
| 30 |
return
|
| 31 |
|
| 32 |
texts = [c.text for c in chunks]
|
|
|
|
| 47 |
)
|
| 48 |
print(f"[INFO] Indexados chunks {i} a {min(i+batch_size, len(chunks))}/{len(chunks)}")
|
| 49 |
|
| 50 |
+
print(f"[INFO] Indexação concluída. Total: {collection.count()} chunks")
|
| 51 |
|
| 52 |
|
| 53 |
def query_store(query_embedding: list[float], top_k: int):
|