add logger.debug for mongo_impl get_by_mode_and_id()
This commit is contained in:
@@ -45,7 +45,9 @@ class MongoKVStorage(BaseKVStorage):
|
|||||||
for mode, items in data.items():
|
for mode, items in data.items():
|
||||||
for k, v in tqdm_async(items.items(), desc="Upserting"):
|
for k, v in tqdm_async(items.items(), desc="Upserting"):
|
||||||
key = f"{mode}_{k}"
|
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:
|
if result.upserted_id:
|
||||||
logger.debug(f"\nInserted new document with key: {key}")
|
logger.debug(f"\nInserted new document with key: {key}")
|
||||||
data[mode][k]["_id"] = key
|
data[mode][k]["_id"] = key
|
||||||
@@ -54,20 +56,20 @@ class MongoKVStorage(BaseKVStorage):
|
|||||||
self._data.update_one({"_id": k}, {"$set": v}, upsert=True)
|
self._data.update_one({"_id": k}, {"$set": v}, upsert=True)
|
||||||
data[k]["_id"] = k
|
data[k]["_id"] = k
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def get_by_mode_and_id(self, mode: str, id: str) -> Union[dict, None]:
|
async def get_by_mode_and_id(self, mode: str, id: str) -> Union[dict, None]:
|
||||||
if "llm_response_cache" == self.namespace:
|
if "llm_response_cache" == self.namespace:
|
||||||
res = {}
|
res = {}
|
||||||
v = self._data.find_one({"_id": mode+"_"+id})
|
v = self._data.find_one({"_id": mode + "_" + id})
|
||||||
if v:
|
if v:
|
||||||
res[id] = v
|
res[id] = v
|
||||||
print(f"find one by:{id}")
|
logger.debug(f"llm_response_cache find one by:{id}")
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def drop(self):
|
async def drop(self):
|
||||||
""" """
|
""" """
|
||||||
pass
|
pass
|
||||||
|
@@ -48,7 +48,11 @@ class Neo4JStorage(BaseGraphStorage):
|
|||||||
URI, auth=(USERNAME, PASSWORD)
|
URI, auth=(USERNAME, PASSWORD)
|
||||||
)
|
)
|
||||||
_database_name = "home database" if DATABASE is None else f"database {DATABASE}"
|
_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:
|
try:
|
||||||
with _sync_driver.session(database=DATABASE) as session:
|
with _sync_driver.session(database=DATABASE) as session:
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user