update
This commit is contained in:
parent
dfc4d1cfa7
commit
1719bd5463
@ -160,6 +160,9 @@ async def converse_with_chat_assistant(
|
|||||||
logger.warning(f"意图分类失败,使用RAG服务: {e}")
|
logger.warning(f"意图分类失败,使用RAG服务: {e}")
|
||||||
|
|
||||||
# ========== 3. RAG历史缓存查找 ==========
|
# ========== 3. RAG历史缓存查找 ==========
|
||||||
|
# 注意:当 KB_PROVIDER=es_bm25 时,内部KB答案应直接来源于 ES 检索结果,
|
||||||
|
# 避免 rag:semantic:cache 抢答导致“curl 与 API 不一致”。
|
||||||
|
if KBConfig.KB_PROVIDER != 'es_bm25':
|
||||||
logger.info(f'[SemanticCache] 准备执行RAG历史缓存查找 | redis={redis is not None} | chat_id={converse_params.chat_id}')
|
logger.info(f'[SemanticCache] 准备执行RAG历史缓存查找 | redis={redis is not None} | chat_id={converse_params.chat_id}')
|
||||||
if redis:
|
if redis:
|
||||||
lookup_hash = get_question_hash(converse_params.question)
|
lookup_hash = get_question_hash(converse_params.question)
|
||||||
@ -187,6 +190,8 @@ async def converse_with_chat_assistant(
|
|||||||
'Transfer-Encoding': 'chunked'
|
'Transfer-Encoding': 'chunked'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
logger.info(f"[SemanticCache] skip lookup because KB_PROVIDER=es_bm25 | chat_id={converse_params.chat_id}")
|
||||||
|
|
||||||
# ========== 4. RAG服务调用(在这里根据 KB_PROVIDER 选择 ragflow / es_bm25) ==========
|
# ========== 4. RAG服务调用(在这里根据 KB_PROVIDER 选择 ragflow / es_bm25) ==========
|
||||||
try:
|
try:
|
||||||
@ -205,9 +210,8 @@ async def converse_with_chat_assistant(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if KBESService.is_confident(metrics):
|
if KBESService.is_confident(metrics):
|
||||||
async def cache_store_func(answer: str):
|
# KB_PROVIDER=es_bm25 时不写入 rag:semantic:cache,避免污染后续命中
|
||||||
if redis and answer and len(answer.strip()) >= 10:
|
cache_store_func = None
|
||||||
await _async_store_qa(converse_params.chat_id, converse_params.question, answer, redis)
|
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
stream_kb_es_response(
|
stream_kb_es_response(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user