mirror of
http://88.130.71.182:3000/BlitTech/contexta_be.git
synced 2026-06-13 08:45:24 +00:00
fixed the RAg in test pipeline issue
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
from qdrant_client.http.models import (
|
||||
Distance, VectorParams, PointStruct, Filter, FieldCondition, MatchValue
|
||||
)
|
||||
from qdrant_client.http.models import Distance, VectorParams, PointStruct
|
||||
from app.config import settings
|
||||
from typing import List, Dict, Any, Optional
|
||||
import logging
|
||||
@@ -103,15 +101,13 @@ class VectorStoreService:
|
||||
collection_name: str,
|
||||
query_vector: List[float],
|
||||
limit: int = 5,
|
||||
score_threshold: float = 0.3,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Search for similar vectors"""
|
||||
"""Search for similar vectors, returning the top-N by cosine score."""
|
||||
try:
|
||||
results = self.client.query_points(
|
||||
collection_name=collection_name,
|
||||
query=query_vector,
|
||||
limit=limit,
|
||||
score_threshold=score_threshold,
|
||||
).points
|
||||
return [
|
||||
{
|
||||
@@ -122,7 +118,7 @@ class VectorStoreService:
|
||||
for r in results
|
||||
]
|
||||
except Exception as e:
|
||||
logger.error(f"Error searching vectors: {e}")
|
||||
logger.error(f"Error searching vectors in '{collection_name}': {e}", exc_info=True)
|
||||
return []
|
||||
|
||||
def delete_by_document_id(self, collection_name: str, document_id: str) -> bool:
|
||||
@@ -131,19 +127,21 @@ class VectorStoreService:
|
||||
self.client.delete(
|
||||
collection_name=collection_name,
|
||||
points_selector=models.FilterSelector(
|
||||
filter=Filter(
|
||||
filter=models.Filter(
|
||||
must=[
|
||||
FieldCondition(
|
||||
models.FieldCondition(
|
||||
key="document_id",
|
||||
match=MatchValue(value=document_id),
|
||||
match=models.MatchValue(value=document_id),
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
wait=True,
|
||||
)
|
||||
logger.info(f"Deleted vectors for document '{document_id}' from '{collection_name}'")
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Error deleting document vectors: {e}")
|
||||
logger.error(f"Error deleting vectors for document '{document_id}' in '{collection_name}': {e}", exc_info=True)
|
||||
return False
|
||||
|
||||
def count_vectors(self, collection_name: str) -> int:
|
||||
|
||||
Reference in New Issue
Block a user