mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-23 03:19:41 +00:00
commit
8c5330f742
3 changed files with 48 additions and 7 deletions
|
|
@ -77,7 +77,11 @@
|
|||
<el-form :model="formData.configJson" label-width="auto" label-position="left" class="custom-form">
|
||||
<div v-for="(row, rowIndex) in chunkedCallInfoFields" :key="rowIndex" class="form-row">
|
||||
<el-form-item v-for="field in row" :key="field.prop" :label="field.label" :prop="field.prop" style="flex: 1;">
|
||||
<el-input v-if="field.type === 'json-textarea'" v-model="formData.configJson[field.prop]" type="textarea"
|
||||
<el-select v-if="field.type === 'select'" v-model="formData.configJson[field.prop]"
|
||||
:placeholder="field.placeholder" class="custom-input-bg" style="width: 100%">
|
||||
<el-option v-for="opt in field.options" :key="opt" :label="opt" :value="opt"></el-option>
|
||||
</el-select>
|
||||
<el-input v-else-if="field.type === 'json-textarea'" v-model="formData.configJson[field.prop]" type="textarea"
|
||||
:rows="3" :placeholder="field.placeholder" class="custom-input-bg">
|
||||
</el-input>
|
||||
<el-input v-else v-model="formData.configJson[field.prop]" :placeholder="field.placeholder"
|
||||
|
|
@ -164,7 +168,8 @@ export default {
|
|||
fields: JSON.parse(item.fields || '[]').map(f => ({
|
||||
label: f.label,
|
||||
prop: f.key,
|
||||
type: f.type === 'dict' ? 'json-textarea' : f.type === 'password' ? 'password' : 'text',
|
||||
type: f.type === 'dict' ? 'json-textarea' : f.type === 'password' ? 'password' : (f.type === 'select' ? 'select' : 'text'),
|
||||
options: f.options || [],
|
||||
placeholder: `请输入${f.key}`
|
||||
}))
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -81,6 +81,11 @@
|
|||
"></el-input>
|
||||
</template>
|
||||
|
||||
<el-select v-else-if="field.type === 'select'" v-model="form.configJson[field.prop]"
|
||||
:placeholder="field.placeholder" style="width: 100%">
|
||||
<el-option v-for="opt in field.options" :key="opt" :label="opt" :value="opt"></el-option>
|
||||
</el-select>
|
||||
|
||||
<el-input v-else v-model="form.configJson[field.prop]" :placeholder="field.placeholder" :type="field.type"
|
||||
:show-password="field.type === 'password'" @focus="
|
||||
isSensitiveField(field.prop)
|
||||
|
|
@ -312,7 +317,10 @@ export default {
|
|||
? "json-textarea"
|
||||
: f.type === "password"
|
||||
? "password"
|
||||
: "text",
|
||||
: f.type === "select"
|
||||
? "select"
|
||||
: "text",
|
||||
options: f.options || [],
|
||||
placeholder: `请输入${f.key}`,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,20 @@ THINKING_DISABLED_DOMAINS = {
|
|||
"bigmodel.cn": {"thinking": {"type": "disabled"}},
|
||||
"moonshot.cn": {"thinking": {"type": "disabled"}},
|
||||
"volces.com": {"thinking": {"type": "disabled"}},
|
||||
"modelarts-maas.com": {"thinking": {"type": "disabled"}},
|
||||
}
|
||||
|
||||
# 域名规则的模型名豁免表: 强制思考模型不接受该参数注入(如 MaaS glm-5.3 传 thinking 必 400)
|
||||
THINKING_DISABLED_MODEL_EXCLUSIONS = {
|
||||
"modelarts-maas.com": ("glm-5.3",),
|
||||
}
|
||||
|
||||
|
||||
class LLMProvider(LLMProviderBase):
|
||||
def __init__(self, config):
|
||||
self.model_name = config.get("model_name")
|
||||
# 可选实例级思考强度: off/disabled/none/disable | low/medium/high | 空/其他=按域名默认
|
||||
self.thinking_mode = str(config.get("thinking") or "").strip().lower()
|
||||
self.api_key = config.get("api_key")
|
||||
if "base_url" in config:
|
||||
self.base_url = config.get("base_url")
|
||||
|
|
@ -80,14 +88,34 @@ class LLMProvider(LLMProviderBase):
|
|||
return dialogue
|
||||
|
||||
def _apply_thinking_disabled(self, request_params: dict):
|
||||
"""根据域名自动禁用思考模式"""
|
||||
"""思考模式控制: 实例配置(thinking)优先, 否则按域名默认表"""
|
||||
mode = getattr(self, "thinking_mode", "")
|
||||
if mode in ("keep", "passthrough", "default"):
|
||||
# 不干预: 既不发 thinking 参数也不查域名表(适用于强制思考/拒绝该参数的模型, 如 MaaS glm-5.3)
|
||||
return
|
||||
if mode in ("off", "disabled", "none", "disable"):
|
||||
request_params.setdefault("extra_body", {}).update({"thinking": {"type": "disabled"}})
|
||||
logger.bind(tag=TAG).info("思考强度=off: 已禁用思考模式(实例配置)")
|
||||
return
|
||||
if mode in ("low", "medium", "high"):
|
||||
request_params.setdefault("extra_body", {}).update(
|
||||
{"reasoning_effort": mode, "thinking": {"type": "enabled"}})
|
||||
logger.bind(tag=TAG).info(f"思考强度={mode}: reasoning_effort 已设置(实例配置)")
|
||||
return
|
||||
parsed_url = urlparse(self.base_url)
|
||||
domain = parsed_url.netloc
|
||||
model_name = (self.model_name or "").lower()
|
||||
for disabled_domain, params in THINKING_DISABLED_DOMAINS.items():
|
||||
if disabled_domain in domain:
|
||||
request_params.setdefault("extra_body", {}).update(params)
|
||||
logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}")
|
||||
if disabled_domain not in domain:
|
||||
continue
|
||||
exclusions = THINKING_DISABLED_MODEL_EXCLUSIONS.get(disabled_domain, ())
|
||||
if any(ex in model_name for ex in exclusions):
|
||||
logger.bind(tag=TAG).info(
|
||||
f"域名 {domain} 命中禁思考规则, 但模型 {self.model_name} 强制思考且拒绝该参数, 跳过注入")
|
||||
break
|
||||
request_params.setdefault("extra_body", {}).update(params)
|
||||
logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}")
|
||||
break
|
||||
|
||||
def response(self, session_id, dialogue, **kwargs):
|
||||
dialogue = self.normalize_dialogue(dialogue)
|
||||
|
|
|
|||
Loading…
Reference in a new issue