From ffab2ccdcd5a17bcdb62d90227be50fc936bcb2e Mon Sep 17 00:00:00 2001 From: sladro Date: Mon, 2 Feb 2026 23:04:27 +0800 Subject: [PATCH] update --- .../module_admin/service/kb_es_service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ruoyi-fastapi-backend/module_admin/service/kb_es_service.py b/ruoyi-fastapi-backend/module_admin/service/kb_es_service.py index d0ccc30..dd46fcb 100644 --- a/ruoyi-fastapi-backend/module_admin/service/kb_es_service.py +++ b/ruoyi-fastapi-backend/module_admin/service/kb_es_service.py @@ -42,8 +42,11 @@ class KBESService: if not question: return [], KBRetrievalMetrics(0.0, 0.0, 0.0, 0, 0.0, False) + # 仅对 KB_PROVIDER=es_bm25:禁用 KBES 检索缓存(避免 curl/API 不一致与历史命中) + enable_retrieval_cache = KBConfig.KB_PROVIDER != 'es_bm25' + cache_hit = False - if redis and KBConfig.KB_CACHE_TTL > 0: + if enable_retrieval_cache and redis and KBConfig.KB_CACHE_TTL > 0: key = cls._cache_key(question) cached = await redis.get(key) if cached: @@ -91,7 +94,7 @@ class KBESService: cache_hit=cache_hit, ) - if redis and KBConfig.KB_CACHE_TTL > 0: + if enable_retrieval_cache and redis and KBConfig.KB_CACHE_TTL > 0: try: key = cls._cache_key(question) await redis.set(