refactor: use a single agent model path

This commit is contained in:
wuyang
2026-07-26 18:50:51 +08:00
parent 2e8e81c790
commit d95d06233f
23 changed files with 330 additions and 454 deletions
+29 -67
View File
@@ -7,96 +7,58 @@
export let showSetDefault = true;
let showWorkspace = false;
const strengths = [
{ key: 'light', label: '轻度' },
{ key: 'medium', label: '' },
{ key: 'high', label: '' },
{ key: 'extreme', label: '极高' }
const modelOptions = [
{ id: 'luna', label: 'Luna', thinking: '开启 · 不分档' },
{ id: 'terra', label: 'Terra', thinking: '开启 · 不分档' },
{ id: 'sol', label: 'Sol', thinking: '开启 · 不分档' },
{ id: 'deepseek-v4-pro', label: 'DeepSeek', thinking: '极高' }
];
const allowed = new Set(modelOptions.map((item) => item.id));
const allowed = new Set([
'chat-light',
'chat-medium',
'chat-high',
'chat-extreme',
'work-light',
'work-medium',
'work-high',
'work-extreme'
]);
$: selected = allowed.has(selectedModels?.[0]) ? selectedModels[0] : 'chat-medium';
$: mode = selected.startsWith('work-') ? 'work' : 'chat';
$: strength = selected.split('-')[1] ?? 'medium';
$: selected = allowed.has(selectedModels?.[0]) ? selectedModels[0] : 'terra';
$: selectedOption = modelOptions.find((item) => item.id === selected) ?? modelOptions[1];
$: availableIds = new Set($models.map((model) => model.id));
$: if ($models.length > 0 && !availableIds.has(selectedModels?.[0])) {
const fallback = availableIds.has('chat-medium')
? 'chat-medium'
: [...allowed].find((id) => availableIds.has(id));
const fallback = availableIds.has('terra')
? 'terra'
: modelOptions.find((item) => availableIds.has(item.id))?.id;
if (fallback) selectedModels = [fallback];
}
const chooseMode = (nextMode: 'chat' | 'work') => {
if (disabled || (mode === 'work' && nextMode === 'chat')) return;
const next = `${nextMode}-${strength}`;
if (availableIds.has(next)) selectedModels = [next];
};
const chooseStrength = (nextStrength: string) => {
if (disabled) return;
const next = `${mode}-${nextStrength}`;
if (availableIds.has(next)) selectedModels = [next];
const chooseModel = (modelId: string) => {
if (disabled || !availableIds.has(modelId)) return;
selectedModels = [modelId];
};
</script>
<div class="flex max-w-fit items-center gap-2 select-none">
<div class="flex max-w-full items-center gap-2 select-none">
<div
class="flex items-center rounded-xl bg-gray-100/90 p-1 text-sm dark:bg-gray-800/90"
aria-label="Agent mode"
class="flex items-center overflow-x-auto rounded-xl border border-gray-200/80 p-1 text-xs dark:border-gray-700/80"
aria-label="模型"
>
<button
type="button"
class="rounded-lg px-3 py-1.5 font-medium transition {mode === 'chat'
? 'bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white'
: 'text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200'}"
on:click={() => chooseMode('chat')}
disabled={disabled || mode === 'work'}
title={mode === 'work' ? '此对话已升级为 Work,不能返回 Chat' : '快速对话'}
>
Chat
</button>
<button
type="button"
class="rounded-lg px-3 py-1.5 font-medium transition {mode === 'work'
? 'bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white'
: 'text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200'}"
on:click={() => chooseMode('work')}
{disabled}
title="长链路、多步骤工作"
>
Work
</button>
</div>
<div
class="flex items-center rounded-xl border border-gray-200/80 p-1 text-xs dark:border-gray-700/80"
aria-label="Inference strength"
>
{#each strengths as item}
{#each modelOptions as item}
<button
type="button"
class="rounded-lg px-2.5 py-1.5 transition {strength === item.key
class="whitespace-nowrap rounded-lg px-2.5 py-1.5 font-medium transition {selected === item.id
? 'bg-gray-900 text-white dark:bg-white dark:text-gray-900'
: 'text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800'}"
on:click={() => chooseStrength(item.key)}
{disabled}
on:click={() => chooseModel(item.id)}
disabled={disabled || ($models.length > 0 && !availableIds.has(item.id))}
title={item.id === 'deepseek-v4-pro' ? 'DeepSeek V4 Pro' : item.label}
>
{item.label}
</button>
{/each}
</div>
<div
class="whitespace-nowrap rounded-xl bg-gray-100/90 px-2.5 py-2 text-xs text-gray-500 dark:bg-gray-800/90 dark:text-gray-400"
title="模型与思考能力是两个独立概念"
>
思考 <span class="font-medium text-gray-800 dark:text-gray-200">{selectedOption.thinking}</span>
</div>
<button
type="button"
class="rounded-xl border border-gray-200/80 p-2 text-gray-500 transition hover:bg-gray-100 hover:text-gray-900 dark:border-gray-700/80 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white"