updated clean of what implemented on BaseVectorStorage

This commit is contained in:
Yannick Stephan
2025-02-16 13:24:42 +01:00
parent ef0e81315f
commit 3eba41aab6
9 changed files with 94 additions and 30 deletions

View File

@@ -227,7 +227,7 @@ class TiDBVectorDBStorage(BaseVectorStorage):
)
self.cosine_better_than_threshold = cosine_threshold
async def query(self, query: str, top_k: int) -> list[dict]:
async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
"""Search from tidb vector"""
embeddings = await self.embedding_func([query])
embedding = embeddings[0]
@@ -249,7 +249,7 @@ class TiDBVectorDBStorage(BaseVectorStorage):
return results
###### INSERT entities And relationships ######
async def upsert(self, data: dict[str, dict]):
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
# ignore, upsert in TiDBKVStorage already
if not len(data):
logger.warning("You insert an empty data to vector DB")
@@ -333,6 +333,14 @@ class TiDBVectorDBStorage(BaseVectorStorage):
return await self.db.query(SQL, params, multirows=True)
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
raise NotImplementedError
@dataclass
class TiDBGraphStorage(BaseGraphStorage):
# db instance must be injected before use