MCPcopy Create free account
hub / github.com/NanGePlus/LightRAGTest / OracleVectorDBStorage

Class OracleVectorDBStorage

LightRAG/lightrag/kg/oracle_impl.py:289–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288@dataclass
289class OracleVectorDBStorage(BaseVectorStorage):
290 cosine_better_than_threshold: float = 0.2
291
292 def __post_init__(self):
293 pass
294
295 async def upsert(self, data: dict[str, dict]):
296 """向向量数据库中插入数据"""
297 pass
298
299 async def index_done_callback(self):
300 pass
301
302 #################### query method ###############
303 async def query(self, query: str, top_k=5) -> Union[dict, list[dict]]:
304 """从向量数据库中查询数据"""
305 embeddings = await self.embedding_func([query])
306 embedding = embeddings[0]
307 # 转换精度
308 dtype = str(embedding.dtype).upper()
309 dimension = embedding.shape[0]
310 embedding_string = "[" + ", ".join(map(str, embedding.tolist())) + "]"
311
312 SQL = SQL_TEMPLATES[self.namespace].format(dimension=dimension, dtype=dtype)
313 params = {
314 "embedding_string": embedding_string,
315 "workspace": self.db.workspace,
316 "top_k": top_k,
317 "better_than_threshold": self.cosine_better_than_threshold,
318 }
319 # print(SQL)
320 results = await self.db.query(SQL, params=params, multirows=True)
321 # print("vector search result:",results)
322 return results
323
324
325@dataclass

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected