feat: 性能插桩、缓存清除端点、LLM top_p 与 JSON 强制输出

- chat_routes.py: 新增 8 阶段性能计时(stages_ms)+ SSE 输出
- sync_routes.py: 新增 POST /cache/clear 缓存清除端点
- engine.py: LLM 调用增加 top_p 参数
- intent_analyzer.py: response_format 加配置开关(INTENT_RESPONSE_FORMAT)
This commit is contained in:
lacerate551
2026-06-21 20:25:12 +08:00
parent c6a17ad1e4
commit 6d5a4b5b5e
4 changed files with 76 additions and 12 deletions

View File

@@ -82,7 +82,7 @@ try:
CLUSTER_SEED_FLOOR, CLUSTER_MAX_BOOST_PER_SECTION, CLUSTER_MAX_SECTIONS,
CLUSTER_SECTION_PREFIX_LEVELS,
# 上下文与生成
LLM_TEMPERATURE, LLM_MAX_TOKENS, RECALL_MULTIPLIER,
LLM_TEMPERATURE, LLM_TOP_P, LLM_MAX_TOKENS, RECALL_MULTIPLIER,
# FAQ 与黑名单
FAQ_RECALL_TOP_K, FAQ_BOOST_AMOUNT, FAQ_DECAY_MONTHS, FAQ_DECAY_RATE, FAQ_DECAY_MAX,
BLACKLIST_MIN_DISLIKES, BLACKLIST_CACHE_TTL,
@@ -2361,6 +2361,7 @@ class RAGEngine:
"",
MODEL,
temperature=LLM_TEMPERATURE,
top_p=LLM_TOP_P,
max_tokens=LLM_MAX_TOKENS,
messages=messages,
error_prefix="[错误]"

View File

@@ -22,7 +22,7 @@ import threading
from dataclasses import dataclass, asdict
from typing import List, Dict, Optional, Tuple
from config import INTENT_TEMPERATURE, INTENT_MAX_TOKENS, INTENT_HISTORY_WINDOW, INTENT_MODEL
from config import INTENT_TEMPERATURE, INTENT_MAX_TOKENS, INTENT_HISTORY_WINDOW, INTENT_MODEL, INTENT_RESPONSE_FORMAT
logger = logging.getLogger(__name__)
@@ -355,17 +355,17 @@ class IntentAnalyzer:
model = self.model or self._get_default_model()
from core.llm_utils import call_llm
content = call_llm(
client,
"",
model,
_llm_kwargs = dict(
temperature=INTENT_TEMPERATURE,
max_tokens=INTENT_MAX_TOKENS,
messages=[
{"role": "system", "content": self.SYSTEM_PROMPT},
{"role": "user", "content": user_prompt}
]
],
)
if INTENT_RESPONSE_FORMAT:
_llm_kwargs["response_format"] = {"type": "json_object"}
content = call_llm(client, "", model, **_llm_kwargs)
# 解析 JSON
result = self._parse_json(content)