add logger.debug for mongo_impl get_by_mode_and_id()

This commit is contained in:
bingo
2025-01-13 07:27:30 +00:00
parent f28b90b2b3
commit 1984da0fd6
2 changed files with 12 additions and 6 deletions

View File

@@ -45,7 +45,9 @@ class MongoKVStorage(BaseKVStorage):
for mode, items in data.items():
for k, v in tqdm_async(items.items(), desc="Upserting"):
key = f"{mode}_{k}"
result = self._data.update_one({"_id": key}, {"$setOnInsert": v}, upsert=True)
result = self._data.update_one(
{"_id": key}, {"$setOnInsert": v}, upsert=True
)
if result.upserted_id:
logger.debug(f"\nInserted new document with key: {key}")
data[mode][k]["_id"] = key
@@ -54,20 +56,20 @@ class MongoKVStorage(BaseKVStorage):
self._data.update_one({"_id": k}, {"$set": v}, upsert=True)
data[k]["_id"] = k
return data
async def get_by_mode_and_id(self, mode: str, id: str) -> Union[dict, None]:
if "llm_response_cache" == self.namespace:
res = {}
v = self._data.find_one({"_id": mode+"_"+id})
v = self._data.find_one({"_id": mode + "_" + id})
if v:
res[id] = v
print(f"find one by:{id}")
logger.debug(f"llm_response_cache find one by:{id}")
return res
else:
return None
else:
return None
async def drop(self):
""" """
pass

View File

@@ -48,7 +48,11 @@ class Neo4JStorage(BaseGraphStorage):
URI, auth=(USERNAME, PASSWORD)
)
_database_name = "home database" if DATABASE is None else f"database {DATABASE}"
with GraphDatabase.driver(URI, auth=(USERNAME, PASSWORD), max_connection_pool_size=MAX_CONNECTION_POOL_SIZE) as _sync_driver:
with GraphDatabase.driver(
URI,
auth=(USERNAME, PASSWORD),
max_connection_pool_size=MAX_CONNECTION_POOL_SIZE,
) as _sync_driver:
try:
with _sync_driver.session(database=DATABASE) as session:
try: