添加日志
This commit is contained in:
parent
9d0b25f944
commit
04ce6c6019
@ -256,7 +256,11 @@ class SemanticCacheService:
|
||||
ex=self.CACHE_TTL_HOURS * 3600
|
||||
)
|
||||
|
||||
logger.info(f"[SemanticCache] 已缓存: {question[:30]}...")
|
||||
logger.info(f"[SemanticCache] 已缓存 | key={cache_key} | question={question[:30]}...")
|
||||
|
||||
# 验证存储是否成功
|
||||
verify = await redis.get(cache_key)
|
||||
logger.info(f"[SemanticCache] 存储验证 | key={cache_key} | found={verify is not None}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
@ -415,8 +419,11 @@ def get_semantic_cache_service() -> SemanticCacheService:
|
||||
# 便捷函数
|
||||
async def lookup_question(chat_id: str, question: str, redis_client=None) -> Optional[Tuple[str, float]]:
|
||||
"""查找缓存问题"""
|
||||
logger.info(f"[SemanticCache.lookup_question] 入参 | chat_id={chat_id} | question={question}")
|
||||
service = get_semantic_cache_service()
|
||||
return await service.lookup(chat_id, question, redis_client)
|
||||
result = await service.lookup(chat_id, question, redis_client)
|
||||
logger.info(f"[SemanticCache.lookup_question] 返回 | result={result is not None}")
|
||||
return result
|
||||
|
||||
|
||||
async def store_qa_pair(chat_id: str, question: str, answer: str, redis_client=None) -> bool:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user