Repository navigation
fix(models): let the request format own endpoint presets - #3651
Merged
Merged
Conversation
The provider endpoint picker listed every preset, so OpenAI showed a "Chat Completions / Responses" picker next to the request format select. It matched presets by base URL only, which made the two disagree (Chat Completions shown while Responses was requested), and switching the format on the /v1/responses preset produced /v1/responses/chat/completions. - Filter endpoint presets by the selected request format and hide the picker when only the current preset remains; region and plan presets that share a format keep the picker. - Match the selected preset by its effective request URL. - When the format changes, move a base URL that is still a preset to the same-host preset of the new format; custom, forced (#), cross-host and cross-plan URLs are left unchanged. Applies to saved providers too. - Extract request URL helpers to modelRequestUrl.ts with unit tests.
The endpoint picker now lists one request format at a time, so preset labels such as "China - Anthropic Format" repeated the request format select. Labels now name only the region or plan; the preset test checks that labels stay distinct within each request format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The model provider editor showed two dropdowns that both chose the API format. For the OpenAI preset, the endpoint picker offered "Chat Completions API" and "Responses API (default)" right next to the request format select (
OpenAI (chat/completions)/OpenAI (responses)). The picker matched presets by base URL only, so it could show "Chat Completions" while the request format and the resolved URL were Responses.The request format select is now the only control for the API format. The endpoint picker only chooses a host, region, or plan within that format.
Type and Areas
Type: bug fix / UI/UX
Areas: web UI (Settings → Models provider editor)
Motivation / Impact
https://api.openai.com/v1+ Responses now selects the Responses preset instead of the Chat Completions one.https://api.openai.com/v1/responses/chat/completions. Now, when the base URL is still a preset, a format change moves it to the preset for the new format on the same host. Examples:/v1/responses→/v1,api.z.ai/api/paas/v4→api.z.ai/api/anthropic. Custom URLs, forced#URLs, and moves that would change host, region, or plan are left alone. This also applies when editing a saved provider whose URL is still a preset.resolveRequestUrl,previewRequestUrl,geminiBaseUrl) moved unchanged fromModelSettingsPage.tsxintomodelRequestUrl.ts, next to the new preset helpers.Remote scenarios: front-end form logic only. Nothing changes in commands, the wire format, or the persisted shape. Saved
provider/base_url/request_urlfields keep their meaning, so peer, remote-control, and dispatch paths are unaffected. Not run in a remote scenario.Verification
pnpm --dir src/web-ui run test:run src/infrastructure/config/services/providerPresets.test.ts src/app/scenes/settings/pages/ai/: 19 files, 130 tests passed. New tests:modelRequestUrl.test.tscovers format filtering, preset matching by effective URL, same-host remap, and that custom,#, cross-host, and cross-plan URLs are kept.ModelSettingsPage.loading.test.tsx→request format and endpoint presetsrenders the real editor and checks three cases: OpenAI has no picker and its URL follows the format; Zhipu keeps a region picker after switching to Anthropic; a saved OpenAI provider moves/v1/responses→/v1instead of appending a second path.pnpm run type-check:webpnpm run check:repo-hygienepnpm run i18n:audit: passed, 0 warningsNot checked visually in the desktop app. The component tests run in jsdom.
Reviewer Notes
Checked refreshed upstream
mainand open PRs (including #3422 and #3230, which touchModelSettingsPage.tsx) before implementation. None changes the endpoint or format pickers.Checklist