fix: tweak thinking interval scheduling
This commit is contained in:
parent
9bfc6f3903
commit
c590aef460
@ -55,6 +55,8 @@ from modules.upload_security import UploadQuarantineManager, UploadSecurityError
|
||||
from modules.personalization_manager import (
|
||||
load_personalization_config,
|
||||
save_personalization_config,
|
||||
THINKING_INTERVAL_MIN,
|
||||
THINKING_INTERVAL_MAX,
|
||||
)
|
||||
from modules.user_container_manager import UserContainerManager
|
||||
from modules.usage_tracker import UsageTracker
|
||||
@ -676,12 +678,18 @@ def apply_thinking_schedule(terminal: WebTerminal):
|
||||
state["fast_streak"] = 0
|
||||
debug_log("[Thinking] 响应失败,下一次强制思考。")
|
||||
return
|
||||
interval = max(0, THINKING_FAST_INTERVAL or 0)
|
||||
if interval > 0 and state.get("fast_streak", 0) >= interval:
|
||||
client.force_thinking_next_call = True
|
||||
state["fast_streak"] = 0
|
||||
debug_log(f"[Thinking] 连续快速 {interval} 次,下一次强制思考。")
|
||||
return
|
||||
custom_interval = getattr(terminal, "thinking_fast_interval", THINKING_FAST_INTERVAL)
|
||||
interval = max(0, custom_interval or 0)
|
||||
if interval > 0:
|
||||
allowed_fast = max(0, interval - 1)
|
||||
if state.get("fast_streak", 0) >= allowed_fast:
|
||||
client.force_thinking_next_call = True
|
||||
state["fast_streak"] = 0
|
||||
if allowed_fast == 0:
|
||||
debug_log("[Thinking] 频率=1,持续思考。")
|
||||
else:
|
||||
debug_log(f"[Thinking] 快速模式已连续 {allowed_fast} 次,下一次强制思考。")
|
||||
return
|
||||
client.force_thinking_next_call = False
|
||||
client.skip_thinking_next_call = False
|
||||
|
||||
@ -1075,7 +1083,16 @@ def get_personalization_settings(terminal: WebTerminal, workspace: UserWorkspace
|
||||
"""获取个性化配置"""
|
||||
try:
|
||||
data = load_personalization_config(workspace.data_dir)
|
||||
return jsonify({"success": True, "data": data})
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": data,
|
||||
"tool_categories": terminal.get_tool_settings_snapshot(),
|
||||
"thinking_interval_default": THINKING_FAST_INTERVAL,
|
||||
"thinking_interval_range": {
|
||||
"min": THINKING_INTERVAL_MIN,
|
||||
"max": THINKING_INTERVAL_MAX
|
||||
}
|
||||
})
|
||||
except Exception as exc:
|
||||
return jsonify({"success": False, "error": str(exc)}), 500
|
||||
|
||||
@ -1089,7 +1106,20 @@ def update_personalization_settings(terminal: WebTerminal, workspace: UserWorksp
|
||||
payload = request.get_json() or {}
|
||||
try:
|
||||
config = save_personalization_config(workspace.data_dir, payload)
|
||||
return jsonify({"success": True, "data": config})
|
||||
try:
|
||||
terminal.apply_personalization_preferences(config)
|
||||
except Exception as exc:
|
||||
debug_log(f"应用个性化偏好失败: {exc}")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": config,
|
||||
"tool_categories": terminal.get_tool_settings_snapshot(),
|
||||
"thinking_interval_default": THINKING_FAST_INTERVAL,
|
||||
"thinking_interval_range": {
|
||||
"min": THINKING_INTERVAL_MIN,
|
||||
"max": THINKING_INTERVAL_MAX
|
||||
}
|
||||
})
|
||||
except ValueError as exc:
|
||||
return jsonify({"success": False, "error": str(exc)}), 400
|
||||
except Exception as exc:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user