sync(server-release): 从 main 同步逻辑改动(不含 API 格式变更)
同步内容: - knowledge/manager.py: VLM max_tokens 512→2048 + reasoning_content fallback - services/feedback.py: FAQ max_tokens 200→512 - services/session.py: 消息排序增加 id DESC 次级排序 - knowledge/image_cleanup.py: 新增图片/VLM缓存孤儿文件清理模块 - knowledge/collection.py: 集合删除时清理孤儿文件 + list_collections 磁盘扫描策略 - knowledge/document.py: 文档删除时清理孤儿文件 - api/chat_routes.py: 新增 _rescue_bm25_divergence 函数(BM25-CE分歧救援) - core/intent_analyzer.py: 使用 get_intent_client 专用客户端 + 移除短追问缓存跳过逻辑 - cleanup_orphans.py: 独立孤儿文件清理脚本
This commit is contained in:
@@ -233,10 +233,10 @@ class IntentAnalyzer:
|
||||
self._exact_cache_max = 500
|
||||
|
||||
def _get_client(self):
|
||||
"""获取 LLM 客户端"""
|
||||
"""获取 LLM 客户端(百炼快速模型)"""
|
||||
if self._client is None:
|
||||
from config import get_llm_client
|
||||
self._client = get_llm_client()
|
||||
from config import get_intent_client
|
||||
self._client = get_intent_client()
|
||||
return self._client
|
||||
|
||||
def _get_cache(self):
|
||||
@@ -309,9 +309,7 @@ class IntentAnalyzer:
|
||||
|
||||
# 2. 尝试从语义缓存获取
|
||||
cache = self._get_cache()
|
||||
# 短追问(如"B3类呢?")严重依赖上下文,embedding 区分度不足易误命中
|
||||
is_short_followup = history and len(query.strip()) < 20
|
||||
if cache and not is_short_followup:
|
||||
if cache:
|
||||
# 使用 query + 历史关键信息作为缓存键
|
||||
cache_key = self._build_cache_key(query, history)
|
||||
cache_emb = self._get_embedding(cache_key)
|
||||
@@ -327,10 +325,7 @@ class IntentAnalyzer:
|
||||
else:
|
||||
logger.warning("意图分析缓存: _get_embedding 返回 None,跳过缓存")
|
||||
else:
|
||||
if is_short_followup:
|
||||
logger.debug(f"跳过语义缓存(短追问依赖上下文): query='{query[:30]}'")
|
||||
elif not cache:
|
||||
logger.warning("意图分析缓存: _get_cache 返回 None,缓存不可用")
|
||||
logger.warning("意图分析缓存: _get_cache 返回 None,缓存不可用")
|
||||
|
||||
# 构建 prompt
|
||||
user_prompt = f"""## 对话历史
|
||||
|
||||
Reference in New Issue
Block a user