feat: add enable_thinking config to control deep reasoning on web console

This commit is contained in:
zhayujie
2026-04-13 16:06:28 +08:00
parent 3f3d0381e5
commit 89a07e8e74
15 changed files with 135 additions and 73 deletions

View File

@@ -160,13 +160,21 @@ class AgentLLMModel(LLMModel):
kwargs['system'] = system_prompt
# Pass context metadata to bot
channel_type = getattr(self, 'channel_type', None)
channel_type = getattr(self, 'channel_type', None) or ''
if channel_type:
kwargs['channel_type'] = channel_type
session_id = getattr(self, 'session_id', None)
if session_id:
kwargs['session_id'] = session_id
# Determine thinking: respect global config, then channel_type
from config import conf
global_thinking = conf().get("enable_thinking", True)
if not global_thinking:
kwargs['thinking'] = {"type": "disabled"}
else:
kwargs['thinking'] = {"type": "enabled"} if channel_type == "web" else {"type": "disabled"}
response = self.bot.call_with_tools(**kwargs)
return self._format_response(response)
else:
@@ -205,13 +213,21 @@ class AgentLLMModel(LLMModel):
kwargs['system'] = system_prompt
# Pass context metadata to bot
channel_type = getattr(self, 'channel_type', None)
channel_type = getattr(self, 'channel_type', None) or ''
if channel_type:
kwargs['channel_type'] = channel_type
session_id = getattr(self, 'session_id', None)
if session_id:
kwargs['session_id'] = session_id
# Determine thinking: respect global config, then channel_type
from config import conf
global_thinking = conf().get("enable_thinking", True)
if not global_thinking:
kwargs['thinking'] = {"type": "disabled"}
else:
kwargs['thinking'] = {"type": "enabled"} if channel_type == "web" else {"type": "disabled"}
stream = self.bot.call_with_tools(**kwargs)
# Convert stream format to our expected format