修复异步问题

This commit is contained in:
Tian jianyong 2025-12-24 20:21:44 +08:00
parent e40a9e5191
commit bfe2492c4a

View File

@ -326,11 +326,8 @@ def stream_ragflow_response(result: Generator, chat_id: str, start_time: float,
if cache_store_func and last_answer and len(last_answer.strip()) >= 10:
try:
import asyncio
cache_task = asyncio.create_task(cache_store_func(last_answer))
cache_task.add_done_callback(
lambda t: logger.info(f'[RAG_CACHE] 缓存存储完成 | chat_id={chat_id} | answer_length={len(last_answer)}')
if not t.exception() else logger.warning(f'[RAG_CACHE] 缓存存储失败: {t.exception()}')
)
asyncio.run(cache_store_func(last_answer))
logger.info(f'[RAG_CACHE] 缓存存储完成 | chat_id={chat_id} | answer_length={len(last_answer)}')
except Exception as cache_err:
logger.warning(f'[RAG_CACHE] 缓存存储失败: {cache_err}')