Daniel.y commited on
Commit
822a4ff
·
unverified ·
2 Parent(s): fa65a80 d17e1be

Merge pull request #1060 from ArindamRoy23/main

Browse files
lightrag/kg/chroma_impl.py CHANGED
@@ -156,7 +156,9 @@ class ChromaVectorDBStorage(BaseVectorStorage):
156
  logger.error(f"Error during ChromaDB upsert: {str(e)}")
157
  raise
158
 
159
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
160
  try:
161
  embedding = await self.embedding_func([query])
162
 
 
156
  logger.error(f"Error during ChromaDB upsert: {str(e)}")
157
  raise
158
 
159
+ async def query(
160
+ self, query: str, top_k: int, ids: list[str] | None = None
161
+ ) -> list[dict[str, Any]]:
162
  try:
163
  embedding = await self.embedding_func([query])
164
 
lightrag/kg/faiss_impl.py CHANGED
@@ -171,7 +171,9 @@ class FaissVectorDBStorage(BaseVectorStorage):
171
  logger.info(f"Upserted {len(list_data)} vectors into Faiss index.")
172
  return [m["__id__"] for m in list_data]
173
 
174
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
175
  """
176
  Search by a textual query; returns top_k results with their metadata + similarity distance.
177
  """
 
171
  logger.info(f"Upserted {len(list_data)} vectors into Faiss index.")
172
  return [m["__id__"] for m in list_data]
173
 
174
+ async def query(
175
+ self, query: str, top_k: int, ids: list[str] | None = None
176
+ ) -> list[dict[str, Any]]:
177
  """
178
  Search by a textual query; returns top_k results with their metadata + similarity distance.
179
  """
lightrag/kg/milvus_impl.py CHANGED
@@ -101,7 +101,9 @@ class MilvusVectorDBStorage(BaseVectorStorage):
101
  results = self._client.upsert(collection_name=self.namespace, data=list_data)
102
  return results
103
 
104
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
105
  embedding = await self.embedding_func([query])
106
  results = self._client.search(
107
  collection_name=self.namespace,
 
101
  results = self._client.upsert(collection_name=self.namespace, data=list_data)
102
  return results
103
 
104
+ async def query(
105
+ self, query: str, top_k: int, ids: list[str] | None = None
106
+ ) -> list[dict[str, Any]]:
107
  embedding = await self.embedding_func([query])
108
  results = self._client.search(
109
  collection_name=self.namespace,
lightrag/kg/mongo_impl.py CHANGED
@@ -938,7 +938,9 @@ class MongoVectorDBStorage(BaseVectorStorage):
938
 
939
  return list_data
940
 
941
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
942
  """Queries the vector database using Atlas Vector Search."""
943
  # Generate the embedding
944
  embedding = await self.embedding_func([query])
 
938
 
939
  return list_data
940
 
941
+ async def query(
942
+ self, query: str, top_k: int, ids: list[str] | None = None
943
+ ) -> list[dict[str, Any]]:
944
  """Queries the vector database using Atlas Vector Search."""
945
  # Generate the embedding
946
  embedding = await self.embedding_func([query])
lightrag/kg/nano_vector_db_impl.py CHANGED
@@ -120,7 +120,9 @@ class NanoVectorDBStorage(BaseVectorStorage):
120
  f"embedding is not 1-1 with data, {len(embeddings)} != {len(list_data)}"
121
  )
122
 
123
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
124
  # Execute embedding outside of lock to avoid long lock times
125
  embedding = await self.embedding_func([query])
126
  embedding = embedding[0]
 
120
  f"embedding is not 1-1 with data, {len(embeddings)} != {len(list_data)}"
121
  )
122
 
123
+ async def query(
124
+ self, query: str, top_k: int, ids: list[str] | None = None
125
+ ) -> list[dict[str, Any]]:
126
  # Execute embedding outside of lock to avoid long lock times
127
  embedding = await self.embedding_func([query])
128
  embedding = embedding[0]
lightrag/kg/oracle_impl.py CHANGED
@@ -417,7 +417,9 @@ class OracleVectorDBStorage(BaseVectorStorage):
417
  self.db = None
418
 
419
  #################### query method ###############
420
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
421
  embeddings = await self.embedding_func([query])
422
  embedding = embeddings[0]
423
  # 转换精度
 
417
  self.db = None
418
 
419
  #################### query method ###############
420
+ async def query(
421
+ self, query: str, top_k: int, ids: list[str] | None = None
422
+ ) -> list[dict[str, Any]]:
423
  embeddings = await self.embedding_func([query])
424
  embedding = embeddings[0]
425
  # 转换精度
lightrag/kg/qdrant_impl.py CHANGED
@@ -123,7 +123,9 @@ class QdrantVectorDBStorage(BaseVectorStorage):
123
  )
124
  return results
125
 
126
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
127
  embedding = await self.embedding_func([query])
128
  results = self._client.search(
129
  collection_name=self.namespace,
 
123
  )
124
  return results
125
 
126
+ async def query(
127
+ self, query: str, top_k: int, ids: list[str] | None = None
128
+ ) -> list[dict[str, Any]]:
129
  embedding = await self.embedding_func([query])
130
  results = self._client.search(
131
  collection_name=self.namespace,
lightrag/kg/tidb_impl.py CHANGED
@@ -306,7 +306,9 @@ class TiDBVectorDBStorage(BaseVectorStorage):
306
  await ClientManager.release_client(self.db)
307
  self.db = None
308
 
309
- async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
 
 
310
  """Search from tidb vector"""
311
  embeddings = await self.embedding_func([query])
312
  embedding = embeddings[0]
 
306
  await ClientManager.release_client(self.db)
307
  self.db = None
308
 
309
+ async def query(
310
+ self, query: str, top_k: int, ids: list[str] | None = None
311
+ ) -> list[dict[str, Any]]:
312
  """Search from tidb vector"""
313
  embeddings = await self.embedding_func([query])
314
  embedding = embeddings[0]