Baktabek commited on
Commit
011512e
·
verified ·
1 Parent(s): 22af138

Fix: Handle memory:// URL for Qdrant with :memory: location

Browse files
app/infrastructure/external/qdrant_retriever.py CHANGED
@@ -23,7 +23,12 @@ class QdrantRetriever(IRetriever):
23
  self.url = url
24
  self.collection_name = collection_name
25
  self.vector_size = vector_size
26
- self.client = AsyncQdrantClient(url=url, api_key=api_key)
 
 
 
 
 
27
 
28
  async def initialize_collection(self) -> None:
29
  """Initialize Qdrant collection"""
@@ -100,25 +105,29 @@ class QdrantRetriever(IRetriever):
100
  alpha: float = 0.5,
101
  filters: Optional[dict] = None,
102
  ) -> List[RetrievalResult]:
103
- """Hybrid search (semantic + keyword)"""
104
- # Simplified - in production combine with keyword search
105
- raise NotImplementedError("Hybrid search requires integration with keyword search")
106
 
107
- async def upsert_points(
108
  self,
109
- points: List[Dict],
 
 
110
  ) -> None:
111
- """Upsert points to collection"""
112
- qdrant_points = [
113
- PointStruct(
114
- id=point["id"],
115
- vector=point["vector"],
116
- payload=point["payload"],
 
 
 
 
117
  )
118
- for point in points
119
- ]
120
 
121
  await self.client.upsert(
122
  collection_name=self.collection_name,
123
- points=qdrant_points,
124
  )
 
23
  self.url = url
24
  self.collection_name = collection_name
25
  self.vector_size = vector_size
26
+
27
+ # Handle in-memory mode
28
+ if url.startswith("memory://"):
29
+ self.client = AsyncQdrantClient(location=":memory:")
30
+ else:
31
+ self.client = AsyncQdrantClient(url=url, api_key=api_key)
32
 
33
  async def initialize_collection(self) -> None:
34
  """Initialize Qdrant collection"""
 
105
  alpha: float = 0.5,
106
  filters: Optional[dict] = None,
107
  ) -> List[RetrievalResult]:
108
+ """Hybrid search (dense + sparse)"""
109
+ # TODO: Implement hybrid search with BM25
110
+ raise NotImplementedError("Hybrid search not yet implemented")
111
 
112
+ async def add_documents(
113
  self,
114
+ vectors: List[List[float]],
115
+ documents: List[Dict],
116
+ ids: Optional[List[str]] = None,
117
  ) -> None:
118
+ """Add documents to collection"""
119
+ points = []
120
+ for i, (vector, doc) in enumerate(zip(vectors, documents)):
121
+ point_id = ids[i] if ids else str(UUID(int=i))
122
+ points.append(
123
+ PointStruct(
124
+ id=point_id,
125
+ vector=vector,
126
+ payload=doc,
127
+ )
128
  )
 
 
129
 
130
  await self.client.upsert(
131
  collection_name=self.collection_name,
132
+ points=points,
133
  )