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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user