A third-party model in Codex (DeepSeek, MiniMax, ...) had its web searches made by asking gpt-6-luna on the Codex account to search through /responses. A ChatGPT account now searches by the ChatGPT backend's /alpha/search, the request Codex's web.run sends by itself with no model turn (codex-rs ext/web-search): one search_query, the account's small model in "model", allowed_callers ["direct"], and external_web_access from the client's web_search tool (#5018: Codex's "cached" sends false; live by default). The output's pages are read by their 80-dash rule and ref_id; the private-use citation marks are dropped. Measured on a real Plus account (2026-11-03, token not refreshed): 151 alpha/search calls left the 5h window at the same percent, ~1.5-2.2s each; 51 searches by gpt-6-luna took 0% -> 1% of it, 7-15s each, ~9-17k tokens in (40 of them: 414,585 in, 10,313 out). The backend answered the same for any "model" (deepseek-v4 too) and any max_output_tokens. - Automatic (and searchInTurn) picks the backend's search for a ChatGPT account; Settings > Web search offers "<id>/@search" as "its web search". "<id>" and "<id>/<model>" saved before still search by that model, so a user's pick is unchanged. - When the backend's search fails, the account's small model searches (codexSearchBy). - Codex web.run's own search for a non-ChatGPT model (alphaSearchHere) and a Responses request's web_search tool pass their mode on. Run at this head (rebased on origin/main), on mote: - go test ./internal/gateway/... ./internal/gui/ ./internal/agent/ -timeout 45m: gateway and agent ok; gui red only on TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote). After the rebase: the gateway's search tests again ok. - searcher-pick.test.cjs: 22/22, chromium + webkit, en/zh (+ the label is in zh, zh-TW, ja, de). - gofmt -l clean; GOOS=linux go vet gateway, provider; GOOS=windows go vet gateway, gui. - Whole GUI suite on the Linux box (wsl-run): not finished when pushed; its reds so far are WebKit pages this doesn't touch (add-provider, API key palette, Routing headers, click-scroll, Codex resets). Broken by hand, each red: the Automatic switch (TestCodexSearchesWith ItsCheapModel, TestChatGPTAccountSearchesByItsWebSearch), the responses.go mode (TestResponsesWebSearchModeKept), the body's mode, the fallback, and the picker option (searcher-pick). Not tried: a real search through magpie in a sandbox (the request shape was tried by hand against the backend); an account out of its allowance (does alpha/search still answer?); the model fallback still searches live when Codex asked cached. Suggested by lucy_85908 on Discord.
120 lines
3.6 KiB
Go
120 lines
3.6 KiB
Go
package gateway
|
|
|
|
import (
|
|
"github.com/yetone/magpie/internal/provider"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// The reasoning level picked in Settings for a model magpie asks on its
|
|
// own, beside the model in use: Image recognition's and the searcher's
|
|
// (MOMO on Discord, "外置模型能不能提供思考深度选项"). Only those calls
|
|
// are asked so; every other request goes as it did.
|
|
|
|
// ModelEfforts are the reasoning levels model ("<provider>/<model>") has,
|
|
// weakest first, for Settings to offer beside it; none for one whose
|
|
// levels aren't known, or a routing group.
|
|
func ModelEfforts(model string) []string {
|
|
p, m, ok := provider.Resolve(model)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return ByStrength(p.Efforts(m))
|
|
}
|
|
|
|
// sideEffort is want fitted to model's own levels: "" when none is
|
|
// wanted, or the model's levels aren't known, so nothing is sent that it
|
|
// might refuse.
|
|
func sideEffort(model, want string) string {
|
|
levels := ModelEfforts(model)
|
|
if want == "" || len(levels) == 0 {
|
|
return ""
|
|
}
|
|
return fitEffort(want, levels)
|
|
}
|
|
|
|
// visionEffort is the level the Image recognition model is asked to read
|
|
// an image at: the one picked in Settings, else magpie's own, the least
|
|
// it has (leastEffort), as a description is wanted quickly.
|
|
func visionEffort(model string) string {
|
|
if e := sideEffort(model, provider.HeldSettings().VisionEffort); e != "" {
|
|
return e
|
|
}
|
|
return leastEffort(model)
|
|
}
|
|
|
|
// leastEffort is the least reasoning model takes: none when it can go
|
|
// without, else its lowest level; "" when its levels aren't known, which
|
|
// leaves it to the vendor.
|
|
func leastEffort(model string) string {
|
|
p, m, ok := provider.Resolve(model)
|
|
if !ok {
|
|
return ""
|
|
}
|
|
levels := p.Efforts(m)
|
|
if len(levels) == 0 {
|
|
return ""
|
|
}
|
|
return fitEffort("none", levels)
|
|
}
|
|
|
|
// VisionEffortNow is the level the Image recognition model in use is
|
|
// asked at when one is picked in Settings ("" when none is): the picked
|
|
// one fitted to the model's levels, for the row to show.
|
|
func VisionEffortNow() string {
|
|
m, ok := seer()
|
|
if !ok {
|
|
return ""
|
|
}
|
|
return sideEffort(m, provider.HeldSettings().VisionEffort)
|
|
}
|
|
|
|
// VisionEfforts are the levels of the model that describes images now.
|
|
func VisionEfforts() []string {
|
|
if m, ok := seer(); ok {
|
|
return ModelEfforts(m)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// searchEffort is the level the searcher's model, provider p's model, is
|
|
// asked to search at: the one picked in Settings fitted to its levels,
|
|
// or "" to send none.
|
|
func searchEffort(p provider.Provider, model string) string {
|
|
if model == "" || model == codexSearchModel {
|
|
return ""
|
|
}
|
|
return sideEffort(p.ID+"/"+model, settings.Load().SearcherEffort)
|
|
}
|
|
|
|
// SearchEffortNow is the level the searcher in use is asked at, when one
|
|
// is picked in Settings.
|
|
func SearchEffortNow() string {
|
|
if p, m, ok := searcher(); ok {
|
|
return searchEffort(p, m)
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// SearchEfforts are the levels of the model that searches now: none for
|
|
// a Kimi Code plan's search service, which has no model.
|
|
func SearchEfforts() []string {
|
|
if p, m, ok := searcher(); ok && m != "" && m != codexSearchModel {
|
|
return ModelEfforts(p.ID + "/" + m)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// replyRoom is the reply limit a side call asked to think at effort is
|
|
// sent with: its usual limit with room for the thinking above it, so a
|
|
// level picked higher doesn't spend the reply on thinking and leave no
|
|
// answer. The model's own limit still caps it (withMaxOutput).
|
|
func replyRoom(usual int, effort string) int {
|
|
switch effort {
|
|
case "", "none":
|
|
return usual
|
|
case "minimal":
|
|
return usual + 1024
|
|
}
|
|
return usual + budgetOf(effortOf(effort))
|
|
}
|