This commit is contained in:
Pursue Wind 2025-07-22 09:10:55 +08:00 committed by GitHub
commit de8e6c50d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,4 @@
-- OpenAI llm 配置增加 enable_thinking 开关
UPDATE `ai_model_provider` SET `fields` =
'[{\"key\": \"base_url\", \"type\": \"string\", \"label\": \"基础URL\", \"selected\": false}, {\"key\": \"model_name\", \"type\": \"string\", \"label\": \"模型名称\", \"selected\": false}, {\"key\": \"api_key\", \"type\": \"string\", \"label\": \"API密钥\", \"selected\": false}, {\"key\": \"temperature\", \"type\": \"number\", \"label\": \"温度\", \"selected\": false}, {\"key\": \"max_tokens\", \"type\": \"number\", \"label\": \"最大令牌数\", \"selected\": false}, {\"key\": \"top_p\", \"type\": \"number\", \"label\": \"top_p值\", \"selected\": false}, {\"key\": \"top_k\", \"type\": \"number\", \"label\": \"top_k值\", \"selected\": false}, {\"key\": \"frequency_penalty\", \"type\": \"number\", \"label\": \"频率惩罚\", \"selected\": false}, {\"key\": \"enable_thinking\", \"type\": \"boolean\", \"label\": \"阿里云Qwen3深度思考开关\", \"default\": \"false\", \"editing\": false, \"selected\": false}]'
WHERE `id` = 'SYSTEM_LLM_openai';

View file

@ -240,6 +240,13 @@ databaseChangeLog:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202506261637.sql
- changeSet:
id: 202507031111
author: chan
changes:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202507031111.sql
- changeSet:
id: 202507031602
author: zjy
@ -260,4 +267,5 @@ databaseChangeLog:
changes:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202507081646.sql
path: classpath:db/changelog/202507081646.sql

View file

@ -355,6 +355,7 @@ LLM:
top_p: 1
top_k: 50
frequency_penalty: 0 # 频率惩罚
enable_thinking: false # 阿里云Qwen3全系列支持思考模式和非思考模式切换 true/false
AliAppLLM:
# 定义LLM API类型
type: AliBL

View file

@ -26,6 +26,7 @@ class LLMProvider(LLMProviderBase):
"temperature": (0.7, lambda x: round(float(x), 1)),
"top_p": (1.0, lambda x: round(float(x), 1)),
"frequency_penalty": (0, lambda x: round(float(x), 1)),
"enable_thinking": (False, lambda x: x.lower() == 'true'),
}
for param, (default, converter) in param_defaults.items():
@ -91,7 +92,10 @@ class LLMProvider(LLMProviderBase):
def response_with_functions(self, session_id, dialogue, functions=None):
try:
stream = self.client.chat.completions.create(
model=self.model_name, messages=dialogue, stream=True, tools=functions
model=self.model_name, messages=dialogue, stream=True, tools=functions,
extra_body={
"enable_thinking": self.enable_thinking
}
)
for chunk in stream: