ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9e823ad4cc |
provider, gui: a custom provider's model can be asked on Gemini alone, beside chat, Responses and Anthropic (Kayphoon on Discord)
Kayphoon: "供应商为自定义的时候 现在已经兼容 gemini 格式了 但是在下方 模型的详细
配比里面还是只能限定 chat 和 anthropic". A custom provider with a Gemini URL
(#1346) offered a model only the APIs among chat, responses and anthropic
it had a URL for, in the chip's "Asked on" menu and in Names & levels' API
row (modelAPIs). The server side refused it too: SetModelAPI and ModelAPI
took only provider.Protocols (chat, responses, anthropic), so Detect APIs →
Each picked model, which can stage gemini for a model that answered only
there, failed the Save with "a model's API is chat, responses or anthropic,
not "gemini"".
- provider: SetModelAPI and ModelAPI take gemini where the provider has a
Gemini URL (modelAPI); the gateway's usable/APIs then send every client's
request for that model to models/{model}:streamGenerateContent under the
Gemini URL, translated from chat or Messages, a Gemini client's relayed.
Native stays "" for such a model, so Pi/omp/droid ask on their own API
and it is translated.
- gui: modelAPIs counts the Gemini URL, so both pickers offer Gemini.
Responses was already offered when its URL is set; decide is never a
model's API. The key protocol picker (per-key, not per-model) is unchanged.
- css: .mname .mapi has min-height, not a fixed 24px: on a phone the web
GUI's 44px options hung out of the box over the reasoning levels (seen
with three options on main too), and four wrap to a second row.
- docs/subsystems/gateway-routing.md says a model set to Gemini is
translated to it. CLI and TUI have no per-model API setting; no new
strings (Gemini and its hint were already translated).
Run:
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok.
- TestModelAPIGemini (new, httptest upstream with chat, Anthropic and
Gemini routes): chat stream, chat JSON, Messages and a Gemini client's
request for the gemini-picked model each hit only
/v1beta/models/gm:streamGenerateContent?alt=sse with x-goog-api-key and
the prompt in contents; the other model stays on chat. With modelAPI put
back to Protocols it FAILs "Gemini picked for a model: a model's API is
... not "gemini""; with Save allowed but ModelAPI still refusing it,
FAILs with chat/messages asked and 503 "no available channel".
- TestModelAPI also checks gemini without a Gemini URL and "decide" are
refused.
- gofmt -l: nothing. go vet, GOOS=linux and GOOS=windows go vet -tags nogui
on internal/provider, internal/gateway, internal/gui: clean.
- GUI: model-api-gemini.test.cjs (new), Chromium and WebKit, en, zh,
zh-TW, ja, de, at 900px and 360px: 20/20. With modelAPIs put back, 20/20
fail; with the fixed 24px height, the ten 360px runs fail. Whole GUI
suite, both engines, concurrency 6: 5150/5196. Every failing file rerun
alone: model-copy-id, agent-models-redraw, library-servers-bulk,
number-units, sessions-*, usage-* pass alone (load). mobile-web,
old-webkit (Safari 15.0), plugin-moved-signin and routing-context-fold,
routing-group-fold, routing-keys-fold (WebKit) fail alone on origin/main
|
||
|
|
b2c97659fb |
gateway: a model picked for Responses is asked on Responses again after the relay once answers it there with "use /v1/chat/completions", not sent as chat from then on (01huadalang on Discord: 为什么会转成 chat,我都设置的 response)
A wrong-endpoint answer marks the model unfit on that API until magpie restarts. With the user's per-model API (Names & levels, ModelAPI) the only API usable gives, one such answer left usable empty, and every later request fell back to p.Speaks(): chat first. Now the fallback is the picked API; without a pick it is Speaks() as before. TestModelAPIPickHoldsAfterWrongEndpoint (a relay with chat and Responses URLs, the model picked for Responses, its first Responses answer a 400 "not supported in /v1/responses, use /v1/chat/completions"; a Responses and a chat client each send twice) fails on the old code (the second request goes to /v1/chat/completions, upstream [/v1/responses /v1/chat/completions ...]) and passes with the change. go test -tags nogui -count=1 ./internal/gateway under a temp HOME passes; go vet (darwin, GOOS=linux, GOOS=windows) on ./internal/gateway passes. Not confirmed that this is the reporter's case: their provider and request weren't seen. |
||
|
|
14b9928d33 |
providers: a relay's APIs found at a click, and a model asked on the one API its vendor serves it on (01huadalang on Discord: 能不能加个供应商检测协议功能,类似 cc 的功能一键检测支持什么协议,发一个最小请求看是否返回200,还有每个模型自定义协议,例如有的供应商一个 api 里有很多模型但是不同协议) — a custom provider was given one base URL and a protocol picked by hand, and which of Chat Completions, Responses and Anthropic Messages a relay answered was learned by trying, one Save and Test at a time. A model's API came only from the vendor's list or a built-in (Copilot, Factory, Bedrock, OpenCode), so a relay serving some models on chat completions and others only on /v1/messages behind one key had every model tried on chat first, and the ones it had no channel for there failed before the gateway got to Anthropic's. The editor's Base URL now has Detect APIs, with a model to try beside it: it posts provider/detect with the form as it stands (the key typed, or the saved one), and Provider.Detect sends each of the three APIs Test's smallest request (tiny: 16 tokens, not streamed) at the URL the provider has for it, else at the URL typed as that API takes it (DetectBase: an endpoint pasted whole cut to its base, …/v1 for OpenAI's two, the root for Anthropic's), in parallel, and says what each answered. With no model typed, one is picked from the provider's list, else from the vendor's /models (asked then and kept nowhere): a Claude model for Anthropic's, an OpenAI one for Responses. Only the URLs typed are asked, only at the click, and nothing is saved. The editor shows each API's URL with its time or its status and error; "Use these" sets the URLs of those that answered (one found missing there, 404 or 405, cleared) and moves the Base URL's protocol to one that did, with no redraw and no scroll. A model's API is new in Names & levels (settings.ModelAPIs, "<provider>/<model>"): for a key's provider with URLs for two or more APIs, each model can be set to Auto or to one of them. It is staged with the rest and made with the Save (ModelPref.API, SetModelAPI), which refuses an API the provider has no URL for and a sign-in's provider. Once set, APIs() returns that API alone, so the gateway, Native and a model's test all ask it there; it is ignored once its URL is gone. After a detection with a model typed where only some APIs answered, "Ask <model> on <API> only" stages the same thing. Gemini isn't probed, since magpie never asks a vendor on it.
The tests run against fake httptest upstreams. TestDetectProtocols covers a bare host, …/v1/ and a pasted …/v1/chat/completions: chat at /v1 and Anthropic at the root are found with gpt-5.5 and claude-sonnet-5 picked from the list, Responses' 404 is reported, the key is sent, no request asks for more than 16 tokens or streams, and nothing is saved. TestDetectModelAndOwnURLs: a typed model is used everywhere and the list isn't fetched, the provider's own Anthropic URL is asked instead of the typed one, and an empty URL or one with no scheme is refused. TestModelAPI: the refusals, the override via SetModelPrefs, APIs/Native/TestModels following it with one request to /v1/messages, the other model unaffected, and "" clearing it. TestModelAPIRoutes: through the gateway, a chat request for the model set to Anthropic reaches only /v1/messages while chat answers "no available channel"; another model still goes to chat. TestProviderDetect covers /api/provider/detect for a new provider's typed key and a saved provider's key, and a Save's modelPrefs.api kept and reported back. TestModelAPI and TestModelAPIRoutes fail without the APIs() override ("apis []"; the upstream asked chat three times). provider-detect.test.cjs runs in WebKit, en and zh, and fails without the change: Detect sends the typed URL and model, the three results are shown, Use these fills Anthropic's URL and keeps chat's, the per-model API picker appears with two URLs and stages only away from Auto, Ask on one API stages it, and Save carries anthropic plus modelPrefs {"m-mixed":{"api":"anthropic"}}. No click moves the page, there is no left-border accent, and every string has Chinese. TestSettingsSaveKeepsWhatItDoesNotSend now covers ModelAPIs. click-scroll, model-test-one, model-test-why, provider-levels-save, provider-levels-scroll, editor-short-window, azure-endpoint, nokey-editor, provider-search, provider-typed, provider-picks-stay and provider-proxy pass in WebKit. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, and go test -tags nogui -count=1 ./... under a temp HOME pass.
|