From 130fbcb8425862f2b62b10ba9cf8fa9b3052da06 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Fri, 9 Oct 2026 21:52:27 +0800 Subject: [PATCH] fix(webui): move API settings into advanced options --- docs/configuration.md | 4 +- .../settings/models/ModelsSettings.tsx | 36 ++++++------- .../settings/models/ProviderSettings.tsx | 51 ++++++++++--------- webui/src/tests/settings-models.test.tsx | 32 +++++++----- webui/src/tests/settings-providers.test.tsx | 10 ++++ 5 files changed, 78 insertions(+), 55 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 9cecfbf01..31533d05a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1458,7 +1458,7 @@ For the built-in `custom` connection or any named custom provider, declare the p `supportedApis` is a nonempty list of `chat_completions`, `responses`, and/or `anthropic_messages`. `preferredApi` must belong to that list and defaults to its first entry. A model preset using Auto inherits this default. A preset's explicit API list must be a subset of the connection's list. A connection can accept both Anthropic and OpenAI formats; automatic fallback stays within the selected API family. -The WebUI custom provider creation and editing forms expose **Supported APIs** and **Default API**. New connections start with Chat Completions; select the protocols your endpoint accepts. Existing connections without an `api` declaration retain their previous automatic routing. Use **Set supported APIs** to add a declaration. Removing a protocol used by an existing explicit model configuration is rejected; update the model configuration first. +The WebUI custom provider creation and editing forms expose **Supported APIs** and **Default API** under **Advanced options**, collapsed by default. New connections start with Chat Completions; select the protocols your endpoint accepts. Existing connections without an `api` declaration retain their previous automatic routing. Use **Set supported APIs** to add a declaration. Removing a protocol used by an existing explicit model configuration is rejected; update the model configuration first. ### Legacy OpenAI API selector migration @@ -1508,7 +1508,7 @@ A custom preset declaring `anthropic_messages` uses the Anthropic adapter for me Omit `api` or set it to `null` for automatic routing. An explicit model declaration overrides the OpenAI connection default. Automatic Copilot routing uses the account's last successfully discovered `supported_endpoints` when available; other automatic routes use registry defaults. Custom gateways use their connection API default when declared, otherwise Chat Completions. A preset can override that default only within the connection's declared supported APIs. Protocol behavior such as reasoning replay and native compaction remains provider-owned; declaring Responses support does not enable OpenAI-native compaction on a custom gateway. -In the WebUI, open **Settings → Models → a preset → API connection**. Choose **Auto**, **Responses**, **Chat Completions**, or **Anthropic Messages**, according to the host's declared adapter support. Auto shows the default API in parentheses, such as **Auto (Responses)**, and updates when the provider, model, or reasoning setting changes. The gateway resolves this default using the same rules as model requests, without probing remote endpoints. The label describes the default preference; compatibility failures can still activate permitted Chat fallback. Hosts that do not advertise API resolution show **Auto** without a resolved label. Selecting Responses also reveals **Try Chat Completions if Responses is unsupported**, which starts off when selecting Responses and requires the same model to support both endpoints. +In the WebUI, open **Settings → Models → a preset → Advanced options → API connection**. Advanced options is collapsed by default; opening or closing it preserves the preset's API declaration. Choose **Auto**, **Responses**, **Chat Completions**, or **Anthropic Messages**, according to the host's declared adapter support. Auto shows the default API in parentheses, such as **Auto (Responses)**, and updates when the provider, model, or reasoning setting changes while Advanced options is open. The gateway resolves this default using the same rules as model requests, without probing remote endpoints. The label describes the default preference; compatibility failures can still activate permitted Chat fallback. Hosts that do not advertise API resolution show **Auto** without a resolved label. Selecting Responses also reveals **Try Chat Completions if Responses is unsupported**, which starts off when selecting Responses and requires the same model to support both endpoints. Every provider adapter declares its request formats in `nanobot/providers/registry.py`. OpenAI Codex, xAI Grok subscriptions, and the Azure OpenAI adapter use Responses; Anthropic uses Messages, and Bedrock uses Converse. The WebUI shows the protocol name for these fixed connections instead of an editable selector. Preset declarations cannot enable a format the adapter does not implement. An OpenAI-compatible adapter implementing both formats does not guarantee that a particular remote model supports both. diff --git a/webui/src/components/settings/models/ModelsSettings.tsx b/webui/src/components/settings/models/ModelsSettings.tsx index bfec55d58..552c1451d 100644 --- a/webui/src/components/settings/models/ModelsSettings.tsx +++ b/webui/src/components/settings/models/ModelsSettings.tsx @@ -238,6 +238,7 @@ export function ModelsSettings({ const tx = (key: string, fallback: string, values?: Record) => t(key, { defaultValue: fallback, ...(values ?? {}) }); const [editorOpen, setEditorOpen] = useState(false); + const [advancedOpen, setAdvancedOpen] = useState(false); const resolvedAutomaticAPI = useAutomaticModelAPI({ token, provider: form.provider, @@ -245,13 +246,12 @@ export function ModelsSettings({ reasoningEffort: form.reasoningEffort, providers: settings.providers, supported: settings.model_api_resolution_supported === true, - editorOpen, + editorOpen: editorOpen && advancedOpen, }); const editorTriggerRef = useRef(null); const presetNameInputRef = useRef(null); const suggestedPresetNameRef = useRef(null); const [editorRowKey, setEditorRowKey] = useState(null); - const [advancedOpen, setAdvancedOpen] = useState(false); const advancedId = useId(); const [draggedCallOrderIndex, setDraggedCallOrderIndex] = useState(null); const [dragOverCallOrderIndex, setDragOverCallOrderIndex] = useState(null); @@ -517,14 +517,6 @@ export function ModelsSettings({ }} /> - provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider), - )} - automaticAPI={resolvedAutomaticAPI?.api} - value={form.api} - onChange={(api) => setForm((prev) => ({ ...prev, api }))} - /> -
- setForm((prev) => ({ ...prev, ...value }))} +
+ provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider), + )} + automaticAPI={resolvedAutomaticAPI?.api} + value={form.api} + onChange={(api) => setForm((prev) => ({ ...prev, api }))} /> +
+ setForm((prev) => ({ ...prev, ...value }))} + /> +
diff --git a/webui/src/components/settings/models/ProviderSettings.tsx b/webui/src/components/settings/models/ProviderSettings.tsx index 1709b8adb..298ff2335 100644 --- a/webui/src/components/settings/models/ProviderSettings.tsx +++ b/webui/src/components/settings/models/ProviderSettings.tsx @@ -459,18 +459,20 @@ function ProviderAdvancedOptions({ fields, form, onChange, + children, footer, }: { fields: ProviderAdvancedField[]; form: ProviderForm; onChange: (value: Partial) => void; + children?: ReactNode; footer?: ReactNode; }) { const { t } = useTranslation(); const [open, setOpen] = useState(false); const enabled = new Set(fields); const contentId = useId(); - if (enabled.size === 0) return null; + if (enabled.size === 0 && !children) return null; const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback }); const thinkingStyleOptions = [ @@ -501,7 +503,8 @@ function ProviderAdvancedOptions({ /> -
+
+ {children}
{enabled.has("thinking_style") ? ( - {settings.provider_api_configuration_supported && ( - setCustomProviderDraft((current) => ({ ...current, api }))} - /> - )} setCustomProviderDraft((current) => ({ ...current, ...value })) } - /> + > + {settings.provider_api_configuration_supported && ( + setCustomProviderDraft((current) => ({ ...current, api }))} + /> + )} +