Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -260,4 +267,5 @@ databaseChangeLog:
changes:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202507081646.sql
path: classpath:db/changelog/202507081646.sql

1 change: 1 addition & 0 deletions main/xiaozhi-server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion main/xiaozhi-server/core/providers/llm/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, config):
"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():
Expand Down Expand Up @@ -91,7 +92,10 @@ def response(self, session_id, dialogue, **kwargs):
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:
Expand Down