fix: web console bot_type

This commit is contained in:
zhayujie
2026-03-17 10:47:41 +08:00
parent 39a5dc64bd
commit 89a4033fbf
2 changed files with 8 additions and 7 deletions

View File

@@ -849,6 +849,7 @@ let configProviders = {};
let configApiBases = {}; let configApiBases = {};
let configApiKeys = {}; let configApiKeys = {};
let configCurrentModel = ''; let configCurrentModel = '';
let configHasBotType = false;
let cfgProviderValue = ''; let cfgProviderValue = '';
let cfgModelValue = ''; let cfgModelValue = '';
@@ -908,6 +909,7 @@ function initConfigView(data) {
configApiBases = data.api_bases || {}; configApiBases = data.api_bases || {};
configApiKeys = data.api_keys || {}; configApiKeys = data.api_keys || {};
configCurrentModel = data.model || ''; configCurrentModel = data.model || '';
configHasBotType = !!data.has_bot_type;
const providerEl = document.getElementById('cfg-provider'); const providerEl = document.getElementById('cfg-provider');
const providerOpts = Object.entries(configProviders).map(([pid, p]) => ({ value: pid, label: p.label })); const providerOpts = Object.entries(configProviders).map(([pid, p]) => ({ value: pid, label: p.label }));
@@ -1069,13 +1071,8 @@ function saveModelConfig() {
const updates = { model: model }; const updates = { model: model };
const p = configProviders[cfgProviderValue]; const p = configProviders[cfgProviderValue];
updates.use_linkai = (cfgProviderValue === 'linkai'); updates.use_linkai = (cfgProviderValue === 'linkai');
// Save bot_type for bot_factory routing. if (configHasBotType) {
// Most providers use their key directly as bot_type. updates.bot_type = (cfgProviderValue === 'linkai') ? '' : cfgProviderValue;
// linkai uses use_linkai flag instead of bot_type.
if (cfgProviderValue === 'linkai') {
updates.bot_type = '';
} else {
updates.bot_type = cfgProviderValue;
} }
if (p && p.api_base_key) { if (p && p.api_base_key) {
const base = document.getElementById('cfg-api-base').value.trim(); const base = document.getElementById('cfg-api-base').value.trim();

View File

@@ -523,6 +523,7 @@ class ConfigHandler:
"title": title, "title": title,
"model": local_config.get("model", ""), "model": local_config.get("model", ""),
"bot_type": local_config.get("bot_type", ""), "bot_type": local_config.get("bot_type", ""),
"has_bot_type": "bot_type" in local_config,
"use_linkai": bool(local_config.get("use_linkai", False)), "use_linkai": bool(local_config.get("use_linkai", False)),
"channel_type": local_config.get("channel_type", ""), "channel_type": local_config.get("channel_type", ""),
"agent_max_context_tokens": local_config.get("agent_max_context_tokens", 50000), "agent_max_context_tokens": local_config.get("agent_max_context_tokens", 50000),
@@ -567,6 +568,9 @@ class ConfigHandler:
file_cfg = json.load(f) file_cfg = json.load(f)
else: else:
file_cfg = {} file_cfg = {}
if "bot_type" in applied and "bot_type" not in file_cfg:
del applied["bot_type"]
local_config.pop("bot_type", None)
file_cfg.update(applied) file_cfg.update(applied)
with open(config_path, "w", encoding="utf-8") as f: with open(config_path, "w", encoding="utf-8") as f:
json.dump(file_cfg, f, indent=4, ensure_ascii=False) json.dump(file_cfg, f, indent=4, ensure_ascii=False)