From e62ed4dbac5956ce410a4661326c8f40e9f74171 Mon Sep 17 00:00:00 2001 From: LTbinglingfeng Date: Sat, 13 Jun 2026 06:02:15 +0800 Subject: [PATCH] feat(provider): add support for disable cooling feature and enhance model configuration options --- .../sheets/forms/BaseProviderForm.tsx | 222 ++++++++++++++---- src/features/providers/types.ts | 5 + .../providers/useProviderWorkbench.ts | 18 ++ src/i18n/locales/en.json | 11 + src/i18n/locales/ru.json | 11 + src/i18n/locales/zh-CN.json | 11 + src/i18n/locales/zh-TW.json | 11 + src/services/api/providers.ts | 65 +++-- src/services/api/transformers.ts | 25 ++ src/types/provider.ts | 7 + 10 files changed, 326 insertions(+), 60 deletions(-) diff --git a/src/features/providers/sheets/forms/BaseProviderForm.tsx b/src/features/providers/sheets/forms/BaseProviderForm.tsx index d4a2881..f8ad727 100644 --- a/src/features/providers/sheets/forms/BaseProviderForm.tsx +++ b/src/features/providers/sheets/forms/BaseProviderForm.tsx @@ -56,6 +56,11 @@ const emptyApiKeyEntry = (): ApiKeyEntryInput => ({ const stripDisableAllRule = (list?: string[]): string[] => (list ?? []).filter((s) => s.trim() !== '*'); +const formatJsonObject = (value?: Record): string => { + if (!value || Object.keys(value).length === 0) return ''; + return JSON.stringify(value, null, 2); +}; + function buildInitialForm( brand: Exclude, resource: ProviderResource | null, @@ -69,13 +74,17 @@ function buildInitialForm( proxyUrl: '', prefix: '', disabled: false, + disableCooling: false, priority: undefined, models: [emptyModel()], headers: [emptyHeader()], excludedModelsText: '', websockets: brand === 'codex' ? false : undefined, cloak: - brand === 'claude' ? { mode: '', strictMode: false, sensitiveWordsText: '' } : undefined, + brand === 'claude' + ? { mode: '', strictMode: false, sensitiveWordsText: '', cacheUserId: false } + : undefined, + experimentalCchSigning: brand === 'claude' ? false : undefined, testModel: brand === 'openaiCompatibility' || brand === 'claude' || brand === 'gemini' ? '' @@ -94,6 +103,7 @@ function buildInitialForm( proxyUrl: '', prefix: cfg.prefix ?? '', disabled: cfg.disabled === true, + disableCooling: cfg.disableCooling === true, priority: cfg.priority, models: cfg.models?.length ? cfg.models.map((m) => ({ @@ -101,6 +111,8 @@ function buildInitialForm( alias: m.alias ?? '', priority: m.priority, testModel: m.testModel, + image: m.image === true, + thinkingJson: formatJsonObject(m.thinking), })) : [emptyModel()], headers: cfg.headers @@ -133,6 +145,7 @@ function buildInitialForm( proxyUrl: cfg.proxyUrl ?? '', prefix: cfg.prefix ?? '', disabled, + disableCooling: cfg.disableCooling === true, priority: cfg.priority, models: cfg.models?.length ? cfg.models.map((m) => ({ @@ -153,8 +166,13 @@ function buildInitialForm( mode: (cfg as ProviderKeyConfig).cloak?.mode ?? '', strictMode: (cfg as ProviderKeyConfig).cloak?.strictMode === true, sensitiveWordsText: (cfg as ProviderKeyConfig).cloak?.sensitiveWords?.join('\n') ?? '', + cacheUserId: (cfg as ProviderKeyConfig).cloak?.cacheUserId === true, } : undefined, + experimentalCchSigning: + brand === 'claude' + ? (cfg as ProviderKeyConfig).experimentalCchSigning === true + : undefined, testModel: brand === 'claude' || brand === 'gemini' ? '' : undefined, }; } @@ -368,7 +386,12 @@ export function BaseProviderForm({ setForm((prev) => ({ ...prev, cloak: { - ...(prev.cloak ?? { mode: '', strictMode: false, sensitiveWordsText: '' }), + ...(prev.cloak ?? { + mode: '', + strictMode: false, + sensitiveWordsText: '', + cacheUserId: false, + }), [key]: value, }, })); @@ -418,6 +441,12 @@ export function BaseProviderForm({ [form.apiKeyEntries] ); const actualApiKeyEntries = form.apiKeyEntries ?? []; + const supportsDisableCooling = + brand === 'gemini' || + brand === 'codex' || + brand === 'claude' || + brand === 'openaiCompatibility'; + const supportsOpenAIModelOptions = brand === 'openaiCompatibility'; const singleConnectivity = brand === 'gemini' ? { status: connectivity.geminiStatus, run: connectivity.runGemini } @@ -444,6 +473,20 @@ export function BaseProviderForm({ ); }; + const updateModelEntry = (idx: number, patch: Partial) => { + updateField( + 'models', + modelsList.map((it, i) => (i === idx ? { ...it, ...patch } : it)) + ); + }; + + const removeModelEntry = (idx: number) => { + updateField( + 'models', + modelsList.filter((_, i) => i !== idx) + ); + }; + return (
{/* 基础字段 */} @@ -661,6 +704,22 @@ export function BaseProviderForm({ ) : null} + + {supportsDisableCooling ? ( + + ) : null} {/* 高级折叠区 */} @@ -906,50 +965,97 @@ export function BaseProviderForm({ onClose={closeDiscovery} /> ) : null} - {modelsList.map((entry, idx) => ( -
- - updateField( - 'models', - modelsList.map((it, i) => (i === idx ? { ...it, name: e.target.value } : it)) - ) - } - disabled={mutating} - /> - - updateField( - 'models', - modelsList.map((it, i) => (i === idx ? { ...it, alias: e.target.value } : it)) - ) - } - disabled={mutating} - /> - +
+
+ updateModelEntry(idx, { name: e.target.value })} + disabled={mutating} + /> + updateModelEntry(idx, { alias: e.target.value })} + disabled={mutating} + /> +
+ +
+ +