修改 bug

This commit is contained in:
Tian jianyong 2025-12-24 18:57:45 +08:00
parent 01f4b2dbac
commit daca304d92
2 changed files with 5 additions and 13 deletions

View File

@ -340,13 +340,13 @@ def stream_ragflow_response(result: Generator, chat_id: str, start_time: float,
total_time = time.perf_counter() - start_time
logger.info(f'[RAG_SERVER {time.time():.3f}] ⏱️ Total Stream Duration ({chat_id}): {total_time:.3f}s')
# 流结束后存储缓存
# 流结束后存储缓存(使用 create_task 确保异步任务被执行)
if cache_store_func and last_answer and len(last_answer.strip()) >= 10:
try:
cache_store_func(last_answer)
logger.info(f'[RAG_CACHE] 流式响应缓存存储 | chat_id={chat_id} | answer_length={len(last_answer)}')
asyncio.create_task(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}')
logger.warning(f'[RAG_CACHE] 缓存存储失败: {cache_err}')
# 聊天助手列表

View File

@ -169,9 +169,6 @@ class MatchService:
kw1 = set(self.extract_keywords(q1))
kw2 = set(self.extract_keywords(q2))
logger.info(f'[MatchDebug] q1={q1} | n1={n1} | kw1={kw1}')
logger.info(f'[MatchDebug] q2={q2} | n2={n2} | kw2={kw2}')
if not kw1 or not kw2:
return 0.0
@ -195,14 +192,9 @@ class MatchService:
for candidate_text, candidate_data in candidates:
similarity = self.calculate_similarity(query, candidate_text)
logger.info(f'[MatchDebug] compare | query="{query}" | candidate="{candidate_text}" | sim={similarity:.3f}')
if similarity > best_similarity:
best_similarity = similarity
best_match = candidate_data
logger.info(f'[MatchDebug] best | query="{query}" | best_sim={best_similarity:.3f} | threshold={threshold}')
best_match = candidate_data
if best_similarity >= threshold:
return best_match, best_similarity