feat: support coding plan

This commit is contained in:
zhayujie
2026-03-18 11:59:22 +08:00
parent b8437032e9
commit 4efae41048
33 changed files with 458 additions and 55 deletions

View File

@@ -992,7 +992,6 @@ let configProviders = {};
let configApiBases = {};
let configApiKeys = {};
let configCurrentModel = '';
let configHasBotType = false;
let cfgProviderValue = '';
let cfgModelValue = '';
@@ -1052,7 +1051,6 @@ function initConfigView(data) {
configApiBases = data.api_bases || {};
configApiKeys = data.api_keys || {};
configCurrentModel = data.model || '';
configHasBotType = !!data.has_bot_type;
const providerEl = document.getElementById('cfg-provider');
const providerOpts = Object.entries(configProviders).map(([pid, p]) => ({ value: pid, label: p.label }));
@@ -1214,8 +1212,10 @@ function saveModelConfig() {
const updates = { model: model };
const p = configProviders[cfgProviderValue];
updates.use_linkai = (cfgProviderValue === 'linkai');
if (configHasBotType) {
updates.bot_type = (cfgProviderValue === 'linkai') ? '' : cfgProviderValue;
if (cfgProviderValue === 'linkai') {
updates.bot_type = '';
} else {
updates.bot_type = cfgProviderValue;
}
if (p && p.api_base_key) {
const base = document.getElementById('cfg-api-base').value.trim();

View File

@@ -551,7 +551,7 @@ class ConfigHandler:
"api_base_default": "https://generativelanguage.googleapis.com",
"models": [const.GEMINI_31_FLASH_LITE_PRE, const.GEMINI_31_PRO_PRE, const.GEMINI_3_FLASH_PRE],
}),
("chatGPT", {
("openai", {
"label": "OpenAI",
"api_key_field": "open_ai_api_key",
"api_base_key": "open_ai_api_base",
@@ -625,8 +625,7 @@ class ConfigHandler:
"use_agent": use_agent,
"title": title,
"model": local_config.get("model", ""),
"bot_type": local_config.get("bot_type", ""),
"has_bot_type": "bot_type" in local_config,
"bot_type": "openai" if local_config.get("bot_type") == "chatGPT" else local_config.get("bot_type", ""),
"use_linkai": bool(local_config.get("use_linkai", False)),
"channel_type": local_config.get("channel_type", ""),
"agent_max_context_tokens": local_config.get("agent_max_context_tokens", 50000),
@@ -671,9 +670,6 @@ class ConfigHandler:
file_cfg = json.load(f)
else:
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)
with open(config_path, "w", encoding="utf-8") as f:
json.dump(file_cfg, f, indent=4, ensure_ascii=False)