This commit is contained in:
sladro 2026-02-02 23:04:27 +08:00
parent 1719bd5463
commit ffab2ccdcd

View File

@ -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(