ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
253aee08b4 |
provider: an AI Studio key's Gemini URL is filled in once, and stays empty when the user clears it
|
||
|
|
3e61d814e5 |
gateway: an AI Studio key speaks the Gemini API too, and searches by googleSearch
cocoasoda (Discord) asked for a native Gemini API mode on the Gemini API provider, so it can search with Google Search on the API credit a Gemini subscription comes with. The Google Gemini preset (and any provider whose Chat URL is AI Studio's OpenAI-compatible one) now gets AI Studio's Gemini API base, https://generativelanguage.googleapis.com/v1beta, at the same key, filled in by normalize, so existing providers get it on load. A Gemini URL of the provider's own is kept; other hosts, Vertex and sign-ins get nothing. Ordinary turns stay on Chat as before. What changes: - A Gemini client (Gemini CLI) is relayed natively, its googleSearch tool included, instead of being translated onto Chat. - A web search with no tools of the client's own (Claude Code's WebSearch) goes to the Gemini API with tools [{"googleSearch":{}}], and the grounding comes back as the client's search result. - A turn with function tools stays on Chat: Gemini doesn't take googleSearch beside function declarations, so before this the switch to Gemini dropped the search silently. Its model is given magpie's search tool, and the same key answers it by a tool-less googleSearch request (searchesOwn / ownSearcher, as Google sign-ins do since #757), on the user's own credit, not another provider's. - The model list isn't asked twice: AI Studio's OpenAI-compatible list is its Gemini API's list. Run on mote at this change on |
||
|
|
844b9ca3ac |
provider, gateway, gui: a custom provider's Base URL can be a Gemini API (generateContent): …/v1beta, its models listed from it, the key sent in x-goog-api-key (#1346, NagaseMinato)
The custom provider editor's Base URL has a fifth API, "Gemini compatible"
(Gemini 兼容 / Gemini 互換 / Gemini-kompatibel), beside OpenAI, Anthropic and
Responses; More endpoints has a Gemini URL; the CLI takes gemini=. A
Gemini URL is kept as its base (…/v1beta, a relay's path prefix kept, a
pasted models/…:generateContent cut off). Every client's request, Chat,
Messages, Responses or Gemini, streamed or not, goes upstream to
models/{model}:streamGenerateContent?alt=sse under it, with no model in
the body and the key in x-goog-api-key; models are listed from its
/models, a page at a time, keeping those that serve generateContent.
Detect doesn't ask a Gemini API and is hidden while it is picked.
Factory's Gemini route and Bearer token are unchanged.
With five APIs the pick no longer fits a 900px editor in English and
German, so it wraps to a second row, and its thumb now follows the
picked option onto that row.
Verified against fake httptest upstreams only; no real Gemini key or
relay was tried:
- TestCustomGeminiUpstream (gateway): chat, chat stream, messages, a
Gemini client's stream and non-stream, behind /proxy/v1beta. Fails with
"chat: 404" without the gateway.go change.
- TestCustomGeminiProvider, TestGeminiBase, TestFactoryGeminiUnchanged
(provider).
- go vet, HOME=$(mktemp -d) go test -tags nogui ./... (44 packages ok),
GOOS=linux and GOOS=windows go vet on the touched packages.
- provider-gemini.test.cjs (new, en/zh/ja/de, Chromium + WebKit, 8 pass;
fails with "900px: the thumb is 22px off" without the slide() fix),
and in both engines: provider-base-api, provider-detect,
provider-detect-models, provider-add-models, provider-output-picks,
provider-search, provider-url-each-api, seg-contrast, settings-groups,
menu-scroll, click-scroll, ledger-hscroll, strip-scrollbar,
view-scrollbar, usage-ledger-chart, system-one, gui-ja, gui-de,
gui-zh-tw: all pass.
|