fix(web): persist thinking mode toggle
This commit is contained in:
parent
7ca7bddba4
commit
041c79f3b7
@ -252,10 +252,7 @@ class WebTerminal(MainTerminal):
|
||||
# 构建状态信息
|
||||
status = {
|
||||
"project_path": self.project_path,
|
||||
"thinking_mode": {
|
||||
"enabled": self.thinking_mode,
|
||||
"label": self.get_thinking_mode_status()
|
||||
},
|
||||
"thinking_mode": self.thinking_mode,
|
||||
"thinking_status": self.get_thinking_mode_status(),
|
||||
"context": {
|
||||
"usage_percent": context_status['usage_percent'],
|
||||
|
||||
@ -592,11 +592,7 @@ async function bootstrapApp() {
|
||||
this.socket.on('system_ready', (data) => {
|
||||
this.projectPath = data.project_path || '';
|
||||
this.agentVersion = data.version || this.agentVersion;
|
||||
if (typeof data.thinking_mode === 'object') {
|
||||
this.thinkingMode = !!data.thinking_mode.enabled;
|
||||
} else {
|
||||
this.thinkingMode = data.thinking_mode === '思考模式';
|
||||
}
|
||||
this.thinkingMode = !!data.thinking_mode;
|
||||
console.log('系统就绪:', data);
|
||||
|
||||
// 系统就绪后立即加载对话列表
|
||||
@ -1293,7 +1289,6 @@ async function bootstrapApp() {
|
||||
this.toolMenuOpen = false;
|
||||
this.toolSettingsLoading = false;
|
||||
this.toolSettings = [];
|
||||
this.thinkingMode = false;
|
||||
|
||||
console.log('前端状态重置完成');
|
||||
},
|
||||
@ -1326,11 +1321,7 @@ async function bootstrapApp() {
|
||||
const statusData = await statusResponse.json();
|
||||
this.projectPath = statusData.project_path || '';
|
||||
this.agentVersion = statusData.version || this.agentVersion;
|
||||
if (statusData.thinking_mode) {
|
||||
this.thinkingMode = !!statusData.thinking_mode.enabled;
|
||||
} else {
|
||||
this.thinkingMode = false;
|
||||
}
|
||||
this.thinkingMode = !!statusData.thinking_mode;
|
||||
|
||||
// 获取当前对话信息
|
||||
const statusConversationId = statusData.conversation && statusData.conversation.current_id;
|
||||
|
||||
@ -538,7 +538,7 @@
|
||||
class="menu-btn mode-entry"
|
||||
@click="toggleThinkingMode"
|
||||
:disabled="streamingMessage || !isConnected">
|
||||
{{ thinkingMode ? '当前:思考模式(点此切换为快速模式)' : '当前:快速模式(点此切换为思考模式)' }}
|
||||
{{ thinkingMode ? '思考模式' : '快速模式' }}
|
||||
</button>
|
||||
<button type="button"
|
||||
class="menu-btn compress-entry"
|
||||
|
||||
@ -47,6 +47,10 @@ class DeepSeekClient:
|
||||
}
|
||||
self.thinking_mode = thinking_mode # True=智能思考模式, False=快速模式
|
||||
self.web_mode = web_mode # Web模式标志,用于禁用print输出
|
||||
# 兼容旧代码路径
|
||||
self.api_base_url = self.fast_api_config["base_url"]
|
||||
self.api_key = self.fast_api_config["api_key"]
|
||||
self.model_id = self.fast_api_config["model_id"]
|
||||
# 每个任务的独立状态
|
||||
self.current_task_first_call = True # 当前任务是否是第一次调用
|
||||
self.current_task_thinking = "" # 当前任务的思考内容
|
||||
|
||||
@ -69,13 +69,6 @@ stop_flags: Dict[str, Dict[str, Any]] = {}
|
||||
|
||||
DEFAULT_PORT = 8091
|
||||
|
||||
def serialize_thinking_mode(terminal: WebTerminal) -> Dict[str, Any]:
|
||||
"""构造思考模式状态payload,包含是否启用与显示标签。"""
|
||||
return {
|
||||
"enabled": bool(getattr(terminal, "thinking_mode", False)),
|
||||
"label": terminal.get_thinking_mode_status() if hasattr(terminal, "get_thinking_mode_status") else ("思考模式" if getattr(terminal, "thinking_mode", False) else "快速模式")
|
||||
}
|
||||
|
||||
def format_read_file_result(result_data: Dict) -> str:
|
||||
"""格式化 read_file 工具的输出,便于在Web端展示。"""
|
||||
if not isinstance(result_data, dict):
|
||||
@ -1088,7 +1081,7 @@ def handle_connect():
|
||||
reset_system_state(terminal)
|
||||
emit('system_ready', {
|
||||
'project_path': str(workspace.project_path),
|
||||
'thinking_mode': serialize_thinking_mode(terminal),
|
||||
'thinking_mode': bool(getattr(terminal, "thinking_mode", False)),
|
||||
'version': AGENT_VERSION
|
||||
}, room=request.sid)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user