From daca304d92dac2109bf6ef5d66da1c70b64d4d58 Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Wed, 24 Dec 2025 18:57:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_admin/controller/ragflow_controller.py | 8 ++++---- ruoyi-fastapi-backend/utils/match_service.py | 10 +--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ruoyi-fastapi-backend/module_admin/controller/ragflow_controller.py b/ruoyi-fastapi-backend/module_admin/controller/ragflow_controller.py index 7e59392..e2a0770 100644 --- a/ruoyi-fastapi-backend/module_admin/controller/ragflow_controller.py +++ b/ruoyi-fastapi-backend/module_admin/controller/ragflow_controller.py @@ -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}') # 聊天助手列表 diff --git a/ruoyi-fastapi-backend/utils/match_service.py b/ruoyi-fastapi-backend/utils/match_service.py index 5ba2f72..e1e5627 100644 --- a/ruoyi-fastapi-backend/utils/match_service.py +++ b/ruoyi-fastapi-backend/utils/match_service.py @@ -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