Merge pull request #883 from YanSte/fix-return-none

Optimised returns
This commit is contained in:
Yannick Stephan
2025-02-19 22:24:50 +01:00
committed by GitHub
12 changed files with 60 additions and 31 deletions

View File

@@ -108,8 +108,12 @@ class MongoKVStorage(BaseKVStorage):
return keys - existing_ids
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
logger.info(f"Inserting {len(data)} to {self.namespace}")
if not data:
return
if is_namespace(self.namespace, NameSpace.KV_STORE_LLM_RESPONSE_CACHE):
update_tasks = []
update_tasks: list[Any] = []
for mode, items in data.items():
for k, v in items.items():
key = f"{mode}_{k}"
@@ -181,7 +185,10 @@ class MongoDocStatusStorage(DocStatusStorage):
return data - existing_ids
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
update_tasks = []
logger.info(f"Inserting {len(data)} to {self.namespace}")
if not data:
return
update_tasks: list[Any] = []
for k, v in data.items():
data[k]["_id"] = k
update_tasks.append(
@@ -855,10 +862,9 @@ class MongoVectorDBStorage(BaseVectorStorage):
logger.debug("vector index already exist")
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
logger.debug(f"Inserting {len(data)} vectors to {self.namespace}")
logger.info(f"Inserting {len(data)} to {self.namespace}")
if not data:
logger.warning("You are inserting an empty data set to vector DB")
return []
return
list_data = [
{