fixed bugs

This commit is contained in:
belviskhoremk
2026-02-22 23:46:16 +00:00
parent 88ca23adde
commit 6fc607e32c
7 changed files with 195 additions and 10 deletions

View File

@@ -29,7 +29,6 @@ class VectorStoreService:
self.client = get_qdrant_client()
def create_collection(self, collection_name: str) -> bool:
"""Create a new collection for a chatbot"""
try:
self.client.create_collection(
collection_name=collection_name,
@@ -38,6 +37,12 @@ class VectorStoreService:
distance=Distance.COSINE,
),
)
# Create payload index for filtering/deleting by document_id
self.client.create_payload_index(
collection_name=collection_name,
field_name="document_id",
field_schema="keyword",
)
logger.info(f"Created collection: {collection_name}")
return True
except Exception as e:
@@ -102,12 +107,12 @@ class VectorStoreService:
) -> List[Dict[str, Any]]:
"""Search for similar vectors"""
try:
results = self.client.search(
results = self.client.query_points(
collection_name=collection_name,
query_vector=query_vector,
query=query_vector,
limit=limit,
score_threshold=score_threshold,
)
).points
return [
{
"id": str(r.id),