mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge 21ca10cecb into eb14e50941
This commit is contained in:
commit
de8e6c50d5
4 changed files with 19 additions and 2 deletions
|
|
@ -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';
|
||||||
|
|
@ -240,6 +240,13 @@ databaseChangeLog:
|
||||||
- sqlFile:
|
- sqlFile:
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202506261637.sql
|
path: classpath:db/changelog/202506261637.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202507031111
|
||||||
|
author: chan
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202507031111.sql
|
||||||
- changeSet:
|
- changeSet:
|
||||||
id: 202507031602
|
id: 202507031602
|
||||||
author: zjy
|
author: zjy
|
||||||
|
|
@ -260,4 +267,5 @@ databaseChangeLog:
|
||||||
changes:
|
changes:
|
||||||
- sqlFile:
|
- sqlFile:
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202507081646.sql
|
path: classpath:db/changelog/202507081646.sql
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,7 @@ LLM:
|
||||||
top_p: 1
|
top_p: 1
|
||||||
top_k: 50
|
top_k: 50
|
||||||
frequency_penalty: 0 # 频率惩罚
|
frequency_penalty: 0 # 频率惩罚
|
||||||
|
enable_thinking: false # 阿里云Qwen3全系列支持思考模式和非思考模式切换 true/false
|
||||||
AliAppLLM:
|
AliAppLLM:
|
||||||
# 定义LLM API类型
|
# 定义LLM API类型
|
||||||
type: AliBL
|
type: AliBL
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class LLMProvider(LLMProviderBase):
|
||||||
"temperature": (0.7, lambda x: round(float(x), 1)),
|
"temperature": (0.7, lambda x: round(float(x), 1)),
|
||||||
"top_p": (1.0, 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)),
|
"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():
|
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):
|
def response_with_functions(self, session_id, dialogue, functions=None):
|
||||||
try:
|
try:
|
||||||
stream = self.client.chat.completions.create(
|
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:
|
for chunk in stream:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue