From a394e5f7304dbfa87df18a0e2903059b1d85b239 Mon Sep 17 00:00:00 2001 From: KimiSwitch Dev Date: Thu, 9 Jul 2026 11:00:36 +0800 Subject: [PATCH] refactor: auto-generate model role from model name[provider name] format --- src/App.tsx | 7 ++----- src/components/ProviderEdit.tsx | 17 +++++------------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9348c35..9c4b09d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -391,10 +391,7 @@ export default function App() { }); }} onModelAdd={() => { - const providerModels = Object.values(config.models).filter( - (m) => m.provider === currentProvider.name - ); - const alias = `${currentProvider.name}-${providerModels.length + 1}`; + const alias = `新模型[${currentProvider.name}]`; updateConfig((cfg) => ({ ...cfg, models: { @@ -405,7 +402,7 @@ export default function App() { model: "", max_context_size: getDefaultMaxContextSize(alias), display_name: null, - role: null, + role: `新模型[${currentProvider.name}]`, supports_1m: false, capabilities: [], }, diff --git a/src/components/ProviderEdit.tsx b/src/components/ProviderEdit.tsx index 71e4e57..bb7411f 100644 --- a/src/components/ProviderEdit.tsx +++ b/src/components/ProviderEdit.tsx @@ -379,6 +379,7 @@ function ModelMapping({ for (const dm of discovered) { if (!selected.has(dm.id)) continue; const alias = dm.id.replace(/[^a-zA-Z0-9_-]/g, "-"); + const role = `${dm.id}[${provider.name}]`; const max_context_size = dm.max_context_size ?? getDefaultMaxContextSize(dm.id); toAdd.push({ alias, @@ -386,7 +387,7 @@ function ModelMapping({ model: dm.id, max_context_size, display_name: dm.display_name, - role: null, + role, supports_1m: max_context_size >= 1_000_000, capabilities: [], }); @@ -482,17 +483,9 @@ function ModelMapping({ {models.map((m) => ( - - onModelChange({ - ...m, - role: e.target.value || null, - }) - } - /> + + {m.model ? `${m.model}[${m.provider}]` : m.alias} +