routing: a group's Small context first sends a request to the smallest window that holds it
yg6888 on X (tweet 2123308968848379920): in a group routed Smart, Cursor Plus's Composer and Grok 4.7 were never used. Not a bug: Smart orders by allowance tier, then soonest renewal, then listed order, and never weighs the context window, so the 1M members listed ahead always answered. The small ones were only ever reached as a fallback. Smart itself is unchanged; changing its order would move every Smart user's traffic. A group gets a new routing instead, `fit` (Small context first; 小上下文优先, 小上下文優先, 小さいコンテキスト優先, Kleiner Kontext zuerst): - routes.SmallFirst takes Smart's order and sorts it stably by band (a provider set to be used first, the rest with room, the all but used up) and then by window, the smaller known first, an unknown one last. - Its strategy sets ByWindow, so weighRouted fills Seat.Window from windowIn (the provider's own Contexts, else the catalog's). - roomy already leaves out every member the request is estimated past, so the first left is the smallest that holds it: a small model is never asked for a request too long for it, and keeps its last-resort place as under every routing. - The trace's rows carry `context`; the Routing page says "its 200K context window is the smallest that holds this request". - A group's only: provider.normalize already drops it from a provider and the CLI refuses it there. GUI menu, hint, why-lines, TUI and CLI (`routing=fit`, small-first) carry it; docs/reference.md, the gateway-routing and plugin-runtime pages and the en/zh/ja start pages say it, with the search index rebuilt (via docs-index.mjs; #7065). Run first at the tree rebased on origin/main6e5882109, then at this head's (on 856423806; search index rebuilt; gateway/routes vet, routes, rotation, ./internal/gui, the gateway's new tests and routing-small-first, routing-group-strategy and i18n-keys 42/42 again), mote over its cores with another session's full suite on it and mica's disk full, so on the Linux box (wsl-run) and the Windows box: - go test -tags nogui ./internal/routes ./internal/cli ./internal/tui ./plugins/rotation ./internal/gateway -count=1 -timeout 45m: all ok but gateway, whose one red was this commit's own new test asserting a single group while an auto group for the shared model exists; fixed (FindGroup "group/g") and the window/strategy tests rerun ok, both new ones pass. ./internal/provider ok (its only FAIL was the stale search index, since rebuilt). ./internal/gui -run Budget ok. - Broken by hand: SmallFirst returning Smart's order makes TestSmallFirstOrdersByWindow and the gateway test red ("a short request went to big first"); dropping fit from SaveGroup's whitelist makes the gateway test red ("the group didn't keep Small context first"). - GUI (Chromium + WebKit, en zh zh-TW ja de): routing-small-first, routing-group-strategy, i18n-keys, routing-cheapest-first, routing-free-expiring 112/112 before and after the rebase; every routing*, group* and builtins* file (253): 4139 of 4198, the 59 reds in 11 files that fail the same at origin/main239da9991run alone (57; routing-many-keys moves between languages each run), all filed: #7016, #7097, #6520, #5049, #6512, #4711, #3954, #3799, #4082. - Windows: CGO_ENABLED=0 go vet -tags nogui ./internal/... ./plugins/... ok. gofmt -l clean. Not tried: the full `go test ./...` and darwin vet (mote busy, mica out of disk); a real Cursor/Grok account in a group (the window comes from the same windowIn roomy already trusts). Seen on the way: a recovered "close of closed channel" in continuation_test.go's doneHold fake, no test failed from it.
This commit is contained in:
@@ -2376,6 +2376,17 @@ each of these groups ordered by the share used.
|
||||
time window sends a member first at its hours, and a Pause rule leaves
|
||||
one out at its hours. The Routing page says why the first went first:
|
||||
"costs least on Ollama now — $0.150 in, $0.600 out a million tokens".
|
||||
- **Small context first** (routing groups only): each request goes to the
|
||||
member with the smallest context window that holds it, so the big ones
|
||||
are kept for the long requests only they can take. A member whose window
|
||||
the request is longer than is left out before it is asked, as under every
|
||||
routing, and asked only once every one with room is out of its
|
||||
allowance. Members of one size go as Smart orders them, a member all but
|
||||
used up still goes after those with room, and one whose window isn't
|
||||
known goes after every known one. The window is the one you set for the
|
||||
model, else the model list's. The Routing page says why the first went
|
||||
first: "Composer 2.5's 200K context window is the smallest that holds
|
||||
this request".
|
||||
|
||||
The routings besides Smart are the built-in plugin `rotation` (Routing
|
||||
strategies in Plugins › Built-in). It stays on while a provider or group is
|
||||
@@ -2400,6 +2411,7 @@ depends on the routing:
|
||||
| Use before expiry | Only between accounts in the same pace band that magpie sent the same tokens lately, in practice none since magpie started. |
|
||||
| Speed first | Only between those within a tenth of each other's speed, and among those not measured lately. |
|
||||
| Cheapest first | Only between those that cost the same now, and among those with no known price. |
|
||||
| Small context first | Only between those whose context windows are the same size, after Smart's order, and among those whose window isn't known. |
|
||||
|
||||
For Claude Code and Codex, *Make first* also signs the agent in to that
|
||||
account, because the account the agent is signed in to is first. With
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -199,7 +199,7 @@ the core. The seven other routings are the built-in plugin `rotation`'s.
|
||||
| `routes.Strategy` | `Order(pool, seats) []int`: a permutation of the seats' indexes. `pool` is a provider's id or `group/<id>`, for a strategy that keeps a round per pool. `Exact` keeps the order as given; otherwise a provider's API keys that fit the request better go first, each in its order. `ByUse` puts each seat's recent tokens in the trace; `ByFree` has the gateway fill `Seat.Free`, and `BySpeed` `Seat.TTFT` and `TPS` (its speed lately, gateway `speed.go`), each only for a strategy that asks. | [`routes.go`](../../internal/routes/routes.go) |
|
||||
| `routes.Seat` | What a strategy weighs, read by `weighRouted` under the routing state's lock: its rest key, whether it is an account, whether its allowance is known or it learns it as it answers, the share used, when its windows renew, its weekly pace, its key's weight, whether it rests now, its tokens of the last hours, a prepaid wallet's balance and the provider and unit it is in (`Left`, `LeftIn`, #3950), and, when the strategy asks, whether its model is free, whether its account's plan is free (`FreePlan`, `ByPlan`) and its ms to the first token and tokens a second lately. | [`routes.go`](../../internal/routes/routes.go), [`routing.go`](../../internal/gateway/routing.go) |
|
||||
| `Register`, `Find`, `Apply` | `Register(routing, s)` serves a routing until its remove; registering again stacks, and the last one serves. `Find("")` is `Smart` always. `Apply` fails open: a strategy that panics, or answers what isn't a permutation, leaves the pool in its listed order, logged. Every route is still tried. | [`routes.go`](../../internal/routes/routes.go) |
|
||||
| Strategies | `Smart` (core), and `Ordered`, `Rotate`, `LeastUsed`, `Pace`, `Weighted`, `FreeFirst`, `Fastest`, `Cheapest` (a group's only: `provider.normalize` drops `cheap` from a provider), `Drain` and `FreeExpiring` (a group's only too: free quota first, the soonest lost first, then the paid as `Smart` orders them) in `routes.Builtin`. `Drain` remembers the seat each pool is on (`drains`). `Rotate` keeps a turn per pool and `Weighted` a smooth weighted round (`Round`, `MoveRound`), both moved out of the gateway, and `Fastest` a probe count per pool, so a seat not measured lately gets one request in `ProbeEvery`; `Forget` clears them, `Drain`'s too. | [`strategies.go`](../../internal/routes/strategies.go), [`round.go`](../../internal/routes/round.go) |
|
||||
| Strategies | `Smart` (core), and `Ordered`, `Rotate`, `LeastUsed`, `Pace`, `Weighted`, `FreeFirst`, `Fastest`, `Cheapest` (a group's only: `provider.normalize` drops `cheap` from a provider), `Drain`, `FreeExpiring` (a group's only too: free quota first, the soonest lost first, then the paid as `Smart` orders them) and `SmallFirst` (a group's only too, `fit`: Smart's order sorted by each seat's context window, `Seat.Window`, the smallest first, filled only for a strategy with `ByWindow`) in `routes.Builtin`. `Drain` remembers the seat each pool is on (`drains`). `Rotate` keeps a turn per pool and `Weighted` a smooth weighted round (`Round`, `MoveRound`), both moved out of the gateway, and `Fastest` a probe count per pool, so a seat not measured lately gets one request in `ProbeEvery`; `Forget` clears them, `Drain`'s too. | [`strategies.go`](../../internal/routes/strategies.go), [`round.go`](../../internal/routes/round.go) |
|
||||
| Off | A routing no strategy serves is its listed order. `routingOf` in the gateway reads it as `order` wherever the core asks about a routing (a turn's mark, `sinks`, a rotate group's sessions, a group's heads), so nothing of the routing is left half on. | [`routing.go`](../../internal/gateway/routing.go) |
|
||||
| `plugins/rotation` | Requires `providers` and `gateway`, `Essential`. Apply registers every `routes.Builtin` and removes them when turned off. `InUse` counts the providers and groups providers.json routes by one of them (`provider.Routings`, the file alone, not the catalog); an unreadable providers.json is an error, so it stays on. The gateway's `KeepFresh` watches providers.json too, so a routing set from the CLI or the TUI turns it on within 2s. Off, the window's routing pickers (the provider editor, the Routing groups page's pools and groups) offer Smart alone: their options are marked `data-feature="rotation"` (`routingSegs`). | [`rotation.go`](../../plugins/rotation/rotation.go), [`provider.go`](../../internal/provider/provider.go), [`app.js`](../../internal/gui/assets/app.js) |
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ const groupUsage = `usage:
|
||||
magpie group set deepseek-anywhere routing=cheap # the provider it costs least on now first (DeepSeek's off-peak hours)
|
||||
magpie group set free-pool routing=drain # one account until it is used up, then the next, never back
|
||||
magpie group set checkins routing=expiring # free quota first, the soonest to expire first; paid only when none is left
|
||||
magpie group set mixed routing=fit # the smallest context window that holds the request first; the big ones kept for long requests
|
||||
magpie group pick opus-anywhere copilot/claude-opus-5.5
|
||||
magpie claude group/opus-anywhere`
|
||||
|
||||
@@ -165,6 +166,7 @@ var routingNames = []struct {
|
||||
{provider.Cheapest, "cheap", []string{"cheapest", "cheapest-first", "price", "cost"}},
|
||||
{provider.Drain, "drain", []string{"until-used-up", "use-up", "sticky"}},
|
||||
{provider.FreeExpiring, "expiring", []string{"free-expiring", "free-expiry", "free-soonest", "soonest-free"}},
|
||||
{provider.SmallFirst, "fit", []string{"small-first", "smallest-first", "small-context-first", "context"}},
|
||||
{provider.Manual, "manual", []string{"pick", "picked", "pinned"}},
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ func storedGroups(t *testing.T) []map[string]any {
|
||||
}
|
||||
|
||||
func TestParseRoutingStays(t *testing.T) {
|
||||
for in, want := range map[string]string{"smart": "", "": "", "order": "order", "In-Order": "order", "rotate": "rotate", "usage": "usage", "least-used": "usage", "fast": "fast", "Fastest": "fast", "speed": "fast", "speed-first": "fast", "cheap": "cheap", "Cheapest": "cheap", "cheapest-first": "cheap", "price": "cheap", "expiring": "expiring", "free-expiry": "expiring", "Soonest-Free": "expiring"} {
|
||||
for in, want := range map[string]string{"smart": "", "": "", "order": "order", "In-Order": "order", "rotate": "rotate", "usage": "usage", "least-used": "usage", "fast": "fast", "Fastest": "fast", "speed": "fast", "speed-first": "fast", "cheap": "cheap", "Cheapest": "cheap", "cheapest-first": "cheap", "price": "cheap", "expiring": "expiring", "free-expiry": "expiring", "Soonest-Free": "expiring", "fit": "fit", "small-first": "fit", "Small-Context-First": "fit"} {
|
||||
if got, err := parseRouting(in); err != nil || got != want {
|
||||
t.Errorf("routing %q: %q %v, want %q", in, got, err, want)
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ const usage = `magpie — one place to pick every agent's model
|
||||
or only the models ticked for it, a new one off until it is ticked
|
||||
magpie search [add <api> <key>|rm <api>] Tavily, Brave, Exa, Firecrawl, You.com, DeepSeek, Doubao Search (Volcengine), Yuanbao Search (Tencent Cloud), TinyFish or SearXNG for web search when no provider can search
|
||||
magpie groups routing groups: several models agents pick as one, group/<id>
|
||||
magpie group add <name> models=<m1>,<m2> [routing=smart|order|rotate|usage|pace|weight|free|fast|cheap|drain|expiring] [stays=auto|session|turn|off]
|
||||
magpie group add <name> models=<m1>,<m2> [routing=smart|order|rotate|usage|pace|weight|free|fast|cheap|drain|expiring|fit] [stays=auto|session|turn|off]
|
||||
magpie group <id> | set <id> k=v… | rm <id> show, change or remove one (magpie group help for more)
|
||||
magpie accounts [agent] [--json] every subscription magpie knows, with each one's allowance used and when it resets
|
||||
magpie accounts add <agent> sign in to one more Claude, ChatGPT or Google (Gemini CLI, Antigravity) subscription
|
||||
|
||||
@@ -7,8 +7,9 @@ import (
|
||||
)
|
||||
|
||||
// routing= on a provider spreads requests over its keys or accounts as
|
||||
// the editor's Routing does: fast (fastest, speed) is Speed first; manual
|
||||
// and cheapest are a group's alone, and a name magpie doesn't know is refused.
|
||||
// the editor's Routing does: fast (fastest, speed) is Speed first; manual,
|
||||
// cheapest, expiring and fit are a group's alone, and a name magpie
|
||||
// doesn't know is refused.
|
||||
func TestProviderRoutingPair(t *testing.T) {
|
||||
var p provider.Provider
|
||||
for in, want := range map[string]string{"fast": provider.Fastest, "fastest": provider.Fastest, "Speed": provider.Fastest, "order": provider.Ordered, "smart": ""} {
|
||||
@@ -17,7 +18,7 @@ func TestProviderRoutingPair(t *testing.T) {
|
||||
}
|
||||
}
|
||||
p.Routing = provider.Fastest
|
||||
for _, bad := range []string{"manual", "cheapest"} {
|
||||
for _, bad := range []string{"manual", "cheapest", "expiring", "fit"} {
|
||||
if err := applyPairs(&p, []string{"routing=" + bad}); err == nil || p.Routing != provider.Fastest {
|
||||
t.Errorf("routing=%s taken: %q", bad, p.Routing)
|
||||
}
|
||||
|
||||
@@ -1494,10 +1494,11 @@ func applyPairs(p *provider.Provider, pairs []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r == provider.Manual || r == provider.Cheapest || r == provider.FreeExpiring {
|
||||
if r == provider.Manual || r == provider.Cheapest || r == provider.FreeExpiring || r == provider.SmallFirst {
|
||||
// cheap: its keys and accounts all bill the provider's one
|
||||
// price, so there is nothing to weigh; expiring weighs
|
||||
// several subscriptions' free quota, a group's members
|
||||
// several subscriptions' free quota, a group's members; fit
|
||||
// weighs models' windows, and a provider's serve one
|
||||
return fmt.Errorf("routing=%s is a group's: a provider's keys or accounts are routed smart, order, rotate, usage, pace, weight, free, fast or drain", r)
|
||||
}
|
||||
p.Routing = r
|
||||
|
||||
@@ -1075,9 +1075,9 @@ func sessionNamed(in http.Header) bool {
|
||||
// started side by side then each keep an account of their own until its
|
||||
// allowance runs out, as a user picking the mode with several accounts
|
||||
// expects (connor_yang on Discord: three sessions on two of three
|
||||
// accounts). In order, By weight, Free first, Speed first, Cheapest, Manual
|
||||
// and a plugin's routing pick for their own reasons, and keep their order;
|
||||
// In turn spreads on its own.
|
||||
// accounts). In order, By weight, Free first, Speed first, Cheapest,
|
||||
// Small context first, Manual and a plugin's routing pick for their own
|
||||
// reasons, and keep their order; In turn spreads on its own.
|
||||
func spreadsSessions(mode, routing string) bool {
|
||||
if mode != provider.AffinitySession && mode != provider.AffinityStrict {
|
||||
return false
|
||||
|
||||
@@ -2576,6 +2576,9 @@ type weighing struct {
|
||||
// behind is the accounts on credits weigh put after the others
|
||||
// (creditsBehind), by rest key
|
||||
behind map[string]bool
|
||||
// window is each seat's model's context window, by restID: filled
|
||||
// only when the routing weighs by it (routes.Strategy.ByWindow)
|
||||
window map[string]int
|
||||
}
|
||||
|
||||
// seatPrice is a seat's price at the request's time, as Cheapest weighed
|
||||
@@ -2845,6 +2848,15 @@ func weighRouted(p provider.Provider, cs []candidate, model string, from provide
|
||||
wg.price[c.restID()] = seatPrice{in: pr.Input, out: pr.Output, cache: pr.CacheRead, peak: peak}
|
||||
}
|
||||
}
|
||||
if st.ByWindow {
|
||||
// as roomy reads it: the provider's own, else the catalog's
|
||||
served := sync.OnceValue(provider.Served)
|
||||
wg.window = map[string]int{}
|
||||
for i, c := range cs {
|
||||
seats[i].Window = windowIn(served, c.p, c.model)
|
||||
wg.window[c.restID()] = seats[i].Window
|
||||
}
|
||||
}
|
||||
order := routes.Apply(st, p.ID, seats)
|
||||
out := make([]candidate, 0, len(cs))
|
||||
for _, i := range order {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// A group routed Small context first sends a request to the member with
|
||||
// the smallest context window that holds it (yg6888 on X: Cursor's
|
||||
// Composer at 200K and Grok 4.7 at 256K never answered in a group of 1M
|
||||
// models under Smart). The 1M member is listed first, so Smart sends it
|
||||
// everything; routed fit a short request goes to the small one, and one
|
||||
// longer than the small one's window to the big one, the small one left
|
||||
// out as too small. The trace tells each row's window. Smart on the same
|
||||
// group still goes to the listed first.
|
||||
func TestSmallContextFirstGroupKeepsTheBigOneForLongRequests(t *testing.T) {
|
||||
fresh(t)
|
||||
up := httptest.NewServer(http.HandlerFunc(streamed))
|
||||
t.Cleanup(up.Close)
|
||||
to, _ := url.Parse(up.URL)
|
||||
for _, p := range []provider.Provider{
|
||||
{ID: "big", Name: "Big", Key: "sk-b", Chat: "https://big.example/v1", Models: []string{"m"}, Contexts: map[string]int{"m": 1_000_000}},
|
||||
{ID: "small", Name: "Small", Key: "sk-s", Chat: "https://small.example/v1", Models: []string{"m"}, Contexts: map[string]int{"m": 4_000}},
|
||||
} {
|
||||
if err := provider.Save(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
group := func(routing string) {
|
||||
t.Helper()
|
||||
if err := provider.SaveGroup(provider.Group{Name: "G", Members: []string{"big/m", "small/m"}, Routing: routing}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
s := New()
|
||||
s.client = &http.Client{Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
|
||||
r.URL.Scheme, r.URL.Host = to.Scheme, to.Host
|
||||
return http.DefaultTransport.RoundTrip(r)
|
||||
})}
|
||||
ask := func(text string) *Route {
|
||||
t.Helper()
|
||||
code, body := postAs(t, s, "", `{"model":"group/g","stream":true,"messages":[{"role":"user","content":"`+text+`"}]}`)
|
||||
if code != 200 {
|
||||
t.Fatalf("code %d: %s", code, body)
|
||||
}
|
||||
return s.trace.routes[len(s.trace.routes)-1]
|
||||
}
|
||||
long := strings.Repeat("lorem ipsum dolor sit amet ", 2000) // ~54K characters, past 4K tokens
|
||||
|
||||
group(provider.SmallFirst)
|
||||
if g, _, ok := provider.FindGroup("group/g"); !ok || g.Routing != provider.SmallFirst {
|
||||
t.Fatalf("the group didn't keep Small context first: %+v", g)
|
||||
}
|
||||
short := ask("hi")
|
||||
if short.Order[0].Provider != "small" {
|
||||
t.Fatalf("a short request went to %q first, want small: %+v", short.Order[0].Provider, short.Order)
|
||||
}
|
||||
if short.Order[0].Context != 4_000 {
|
||||
t.Fatalf("the small row doesn't tell its window: %+v", short.Order[0])
|
||||
}
|
||||
if len(short.Tries) != 1 || short.Tries[0].ID != short.Order[0].ID {
|
||||
t.Fatalf("a short request wasn't served by the small one alone: %+v", short.Tries)
|
||||
}
|
||||
big := ask(long)
|
||||
if big.Order[0].Provider != "big" {
|
||||
t.Fatalf("a long request went to %q first, want big: %+v", big.Order[0].Provider, big.Order)
|
||||
}
|
||||
for _, w := range big.Order {
|
||||
if w.Provider == "small" && w.Window != 4_000 {
|
||||
t.Fatalf("the small one wasn't left out as too small for the long request: %+v", w)
|
||||
}
|
||||
}
|
||||
|
||||
// Smart on the same group: the listed first, and no row tells a window
|
||||
group("")
|
||||
smart := ask("hi")
|
||||
if smart.Order[0].Provider != "big" {
|
||||
t.Fatalf("Smart went to %q first, want the listed first: %+v", smart.Order[0].Provider, smart.Order)
|
||||
}
|
||||
for _, w := range smart.Order {
|
||||
if w.Context != 0 {
|
||||
t.Fatalf("a Smart row tells a window: %+v", w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Small context first is a group's: a provider saved with it keeps Smart.
|
||||
func TestSmallContextFirstIsAGroupsOnly(t *testing.T) {
|
||||
fresh(t)
|
||||
if err := provider.Save(provider.Provider{ID: "rl", Name: "Relay", Key: "k", Chat: "https://relay.example/v1", Models: []string{"m"}, Routing: provider.SmallFirst}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p, err := provider.Find("rl"); err != nil || p.Routing != "" {
|
||||
t.Fatalf("a provider kept routing fit, want Smart: %v %+v", err, p)
|
||||
}
|
||||
}
|
||||
@@ -364,6 +364,7 @@ type Weighed struct {
|
||||
LateTTFT float64 `json:"lateTtft,omitempty"` // speed first: its ms to the first token lately, 0 if not measured (speed.go)
|
||||
LateTPS float64 `json:"lateTps,omitempty"` // speed first: its tokens a second lately, 0 if not told
|
||||
Price *SeatPrice `json:"price,omitempty"` // cheapest first: what its model costs on it now, nil if not known
|
||||
Context int `json:"context,omitempty"` // small context first: its model's context window there, 0 if not known
|
||||
Turn bool `json:"turn,omitempty"` // in turn: it was this one's turn
|
||||
Fit int `json:"fit,omitempty"` // keyFit
|
||||
Speaks provider.Protocol `json:"speaks,omitempty"` // a key made for one protocol only
|
||||
@@ -692,6 +693,9 @@ func weighed(c candidate, p provider.Provider, wg weighing, fallback bool, from
|
||||
if pr, ok := wg.price[c.restID()]; ok {
|
||||
w.Price = &SeatPrice{Input: pr.in, Output: pr.out, CacheRead: pr.cache, Peak: pr.peak}
|
||||
}
|
||||
if n, ok := wg.window[c.restID()]; ok {
|
||||
w.Context = n
|
||||
}
|
||||
if sinks(p.Sink, p.Routing) {
|
||||
markSunk(&w, c)
|
||||
}
|
||||
|
||||
@@ -12429,7 +12429,7 @@ const drawRotFig = (b, on, a) => (b.hidden = !on) ? b.replaceChildren() : (drawR
|
||||
// the routings besides Smart are the built-in plugin rotation's
|
||||
// (plugins/rotation): off, their options leave the page (data-feature),
|
||||
// and Smart is left — one in use keeps it on
|
||||
const ROTATION = new Set(["order", "drain", "rotate", "usage", "pace", "weight", "free", "fast", "cheap", "expiring"]);
|
||||
const ROTATION = new Set(["order", "drain", "rotate", "usage", "pace", "weight", "free", "fast", "cheap", "expiring", "fit"]);
|
||||
// jsRoutings: the routings JS gateway plugins serve now ("<plugin>/<name>",
|
||||
// settings' jsRoutings, plugins/middleware's), and saved, a routing none
|
||||
// serves now, shown as it is: its pool is tried in its listed order
|
||||
|
||||
@@ -2344,6 +2344,12 @@ const I18N = {
|
||||
"it costs least now — {price}.": "它此刻最便宜——{price}。",
|
||||
"Cheapest first: {model} costs least on {who} now — {price}.": "最便宜优先:{model} 此刻在 {who} 上最便宜——{price}。",
|
||||
"Cheapest first: no price is known for {model} on {who}, so it goes in its listed place after every one that has a price.": "最便宜优先:不知道 {model} 在 {who} 上的价格,所以它排在所有有价格的后面,按列出的位置。",
|
||||
"Small context first": "小上下文优先",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out.": "小上下文优先:每个请求交给能装下它、上下文窗口最小的成员,大窗口的留给长请求;窗口比请求短的不参与。",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; a member whose window the request is longer than is left out. Members of one size go as Smart orders them, and one whose window isn't known goes last.": "小上下文优先:每个请求交给能装下它、上下文窗口最小的成员,大窗口的留给长请求;窗口比请求短的成员不参与。窗口一样大的按智能的顺序,窗口未知的排最后。",
|
||||
"its {n} context window is the smallest that holds this request.": "它 {n} 的上下文窗口是能装下这个请求的最小的。",
|
||||
"Small context first: {who}'s {n} context window is the smallest that holds this request.": "小上下文优先:{who} 的 {n} 上下文窗口是能装下这个请求的最小的。",
|
||||
"Small context first: no member with a known context window can take this request, so {who} is next.": "小上下文优先:没有已知窗口的成员能接这个请求,所以轮到 {who}。",
|
||||
"Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused.": "先把不花钱的用完:供应商对本订阅的额度或积分不收费的模型排在前面,按它们原来的顺序;这些都不能响应时,才用要花额度的。不花额度的一个都不剩下。",
|
||||
"Free first: the members whose model its vendor serves at no cost to the subscription's allowance or credits go first, then the rest — each whole, over its own accounts or keys as its provider routes them. The free ones are tried before any that spends, so nothing that costs nothing is left unused.": "免费优先:成员中那个模型不花订阅额度或积分的排在前面,其余在后;每个成员整体尝试,各自按其供应商的路由在自己的账号或 Key 间分配。免费的先于任何花额度的,所以不花钱的一个都不剩下。",
|
||||
"Requests spread over the keys or accounts by the weight set beside each: one weighing 3 takes three requests for every one weighing 1 takes, evenly over a few requests. One that fails is passed over while it rests, and the others share its requests; a conversation stays with it as Stays says.": "请求按每个密钥或账号旁设置的权重分配:权重 3 的每接 3 个请求,权重 1 的接 1 个,几个请求之内就均匀分开。出错的在休息期间被跳过,由其他的按各自权重分担;会话按「会话保持」的设置留在原处。",
|
||||
@@ -7835,6 +7841,12 @@ const I18N = {
|
||||
"it costs least now — {price}.": "它此刻最便宜——{price}。",
|
||||
"Cheapest first: {model} costs least on {who} now — {price}.": "最便宜優先:{model} 此刻在 {who} 上最便宜——{price}。",
|
||||
"Cheapest first: no price is known for {model} on {who}, so it goes in its listed place after every one that has a price.": "最便宜優先:不知道 {model} 在 {who} 上的價格,所以它排在所有有價格的後面,按列出的位置。",
|
||||
"Small context first": "小上下文優先",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out.": "小上下文優先:每個請求交給能裝下它、上下文視窗最小的成員,大視窗的留給長請求;視窗比請求短的不參與。",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; a member whose window the request is longer than is left out. Members of one size go as Smart orders them, and one whose window isn't known goes last.": "小上下文優先:每個請求交給能裝下它、上下文視窗最小的成員,大視窗的留給長請求;視窗比請求短的成員不參與。視窗一樣大的按智慧的順序,視窗未知的排最後。",
|
||||
"its {n} context window is the smallest that holds this request.": "它 {n} 的上下文視窗是能裝下這個請求的最小的。",
|
||||
"Small context first: {who}'s {n} context window is the smallest that holds this request.": "小上下文優先:{who} 的 {n} 上下文視窗是能裝下這個請求的最小的。",
|
||||
"Small context first: no member with a known context window can take this request, so {who} is next.": "小上下文優先:沒有已知視窗的成員能接這個請求,所以輪到 {who}。",
|
||||
"Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused.": "先把不花錢的用完:供應商對本訂閱的額度或點數不收費的模型排在前面,按它們原本的順序;這些都不能回應時,才用要花額度的。不花額度的一個都不剩下。",
|
||||
"Free first: the members whose model its vendor serves at no cost to the subscription's allowance or credits go first, then the rest — each whole, over its own accounts or keys as its provider routes them. The free ones are tried before any that spends, so nothing that costs nothing is left unused.": "免費優先:成員中那個模型不花訂閱額度或點數的排在前面,其餘在後;每個成員整體嘗試,各自依其供應商的路由在自己的帳號或 Key 間分配。免費的先於任何花額度的,所以不花錢的一個都不剩下。",
|
||||
"Requests spread over the keys or accounts by the weight set beside each: one weighing 3 takes three requests for every one weighing 1 takes, evenly over a few requests. One that fails is passed over while it rests, and the others share its requests; a conversation stays with it as Stays says.": "請求按每個金鑰或帳號旁設定的權重分配:權重 3 的每接 3 個請求,權重 1 的接 1 個,幾個請求之內就均勻分開。出錯的在休息期間被跳過,由其他的按各自權重分擔;會話按「會話保持」的設定留在原處。",
|
||||
@@ -13295,6 +13307,12 @@ const I18N = {
|
||||
"it costs least now — {price}.": "いま最も安いためです({price})。",
|
||||
"Cheapest first: {model} costs least on {who} now — {price}.": "最安優先:{model} はいま {who} で最も安いです({price})。",
|
||||
"Cheapest first: no price is known for {model} on {who}, so it goes in its listed place after every one that has a price.": "最安優先:{who} での {model} の価格が分からないため、価格のあるものすべての後ろ、設定順の位置に入ります。",
|
||||
"Small context first": "小さいコンテキスト優先",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out.": "小さいコンテキスト優先:各リクエストは、それが収まる中でコンテキストウィンドウが最も小さいメンバーに送られ、大きいものは長いリクエストのために残します。ウィンドウより長いリクエストはそのメンバーに送りません。",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; a member whose window the request is longer than is left out. Members of one size go as Smart orders them, and one whose window isn't known goes last.": "小さいコンテキスト優先:各リクエストは、それが収まる中でコンテキストウィンドウが最も小さいメンバーに送られ、大きいものは長いリクエストのために残します。リクエストがウィンドウより長いメンバーは外します。同じ大きさのメンバーはスマートの順で、ウィンドウが分からないものは最後です。",
|
||||
"its {n} context window is the smallest that holds this request.": "{n} のコンテキストウィンドウが、このリクエストが収まる最小のものです。",
|
||||
"Small context first: {who}'s {n} context window is the smallest that holds this request.": "小さいコンテキスト優先:{who} の {n} のコンテキストウィンドウが、このリクエストが収まる最小のものです。",
|
||||
"Small context first: no member with a known context window can take this request, so {who} is next.": "小さいコンテキスト優先:ウィンドウの分かるメンバーではこのリクエストを受けられないため、次は {who} です。",
|
||||
"Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused.": "無料のものを先に使い切ります:提供元がこのサブスクリプションの利用枠やクレジットを消費しないモデルを、一覧の順に先に試し、それらが応答できないときだけ消費するものへ進みます。無料のものが残ることはありません。",
|
||||
"Free first: the members whose model its vendor serves at no cost to the subscription's allowance or credits go first, then the rest — each whole, over its own accounts or keys as its provider routes them. The free ones are tried before any that spends, so nothing that costs nothing is left unused.": "無料優先:提供元がサブスクリプションの利用枠やクレジットを消費しないモデルのメンバーを先に、残りを後に置きます。各メンバーはまとめて試され、それぞれの提供元のルーティングに従って自分のアカウントや Key に配分されます。無料のものは消費するものより先なので、無料のものは残りません。",
|
||||
"Requests spread over the keys or accounts by the weight set beside each: one weighing 3 takes three requests for every one weighing 1 takes, evenly over a few requests. One that fails is passed over while it rests, and the others share its requests; a conversation stays with it as Stays says.": "各キーやアカウントの横で設定した重みでリクエストを振り分けます。重み 3 のものは、重み 1 のものが 1 件受けるごとに 3 件受け、数件のうちに均等に分かれます。失敗したものは休止中は飛ばされ、他がそれぞれの重みで分担します。会話は「維持」の設定どおりそこにとどまります。",
|
||||
@@ -18798,6 +18816,12 @@ const I18N = {
|
||||
"it costs least now — {price}.": "es kostet jetzt am wenigsten — {price}.",
|
||||
"Cheapest first: {model} costs least on {who} now — {price}.": "Günstigste zuerst: {model} kostet jetzt bei {who} am wenigsten — {price}.",
|
||||
"Cheapest first: no price is known for {model} on {who}, so it goes in its listed place after every one that has a price.": "Günstigste zuerst: Für {model} bei {who} ist kein Preis bekannt, daher kommt es an seinem Platz in der Liste hinter alle mit Preis.",
|
||||
"Small context first": "Kleiner Kontext zuerst",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out.": "Kleiner Kontext zuerst: Jede Anfrage geht an das Mitglied mit dem kleinsten Kontextfenster, in das sie passt, sodass die großen für lange Anfragen bleiben; eines, dessen Fenster sie übersteigt, wird ausgelassen.",
|
||||
"Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; a member whose window the request is longer than is left out. Members of one size go as Smart orders them, and one whose window isn't known goes last.": "Kleiner Kontext zuerst: Jede Anfrage geht an das Mitglied mit dem kleinsten Kontextfenster, in das sie passt, sodass die großen für lange Anfragen bleiben; ein Mitglied, dessen Fenster die Anfrage übersteigt, wird ausgelassen. Mitglieder gleicher Größe gehen in der Reihenfolge von „Intelligent“, eines mit unbekanntem Fenster zuletzt.",
|
||||
"its {n} context window is the smallest that holds this request.": "sein Kontextfenster von {n} ist das kleinste, in das diese Anfrage passt.",
|
||||
"Small context first: {who}'s {n} context window is the smallest that holds this request.": "Kleiner Kontext zuerst: Das Kontextfenster von {who} mit {n} ist das kleinste, in das diese Anfrage passt.",
|
||||
"Small context first: no member with a known context window can take this request, so {who} is next.": "Kleiner Kontext zuerst: Kein Mitglied mit bekanntem Kontextfenster kann diese Anfrage annehmen, daher ist {who} als Nächstes dran.",
|
||||
"Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused.": "Zuerst kommt, was nichts kostet: Modelle, die ihr Anbieter diesem Abonnement ohne Verbrauch von Kontingent oder Guthaben bereitstellt, in ihrer gelisteten Reihenfolge; erst wenn diese nicht antworten können, eines, das verbraucht. Nichts Kostenloses bleibt ungenutzt.",
|
||||
"Free first: the members whose model its vendor serves at no cost to the subscription's allowance or credits go first, then the rest — each whole, over its own accounts or keys as its provider routes them. The free ones are tried before any that spends, so nothing that costs nothing is left unused.": "Kostenlos zuerst: die Mitglieder, deren Modell ihr Anbieter dem Abonnement ohne Verbrauch von Kontingent oder Guthaben bereitstellt, kommen zuerst, dann die übrigen — jedes als Ganzes, über seine eigenen Konten oder Keys, wie es sein Anbieter routet. Die kostenlosen werden vor jedem verbrauchenden versucht, sodass nichts Kostenloses ungenutzt bleibt.",
|
||||
"Requests spread over the keys or accounts by the weight set beside each: one weighing 3 takes three requests for every one weighing 1 takes, evenly over a few requests. One that fails is passed over while it rests, and the others share its requests; a conversation stays with it as Stays says.": "Anfragen verteilen sich nach dem Gewicht neben jedem Schlüssel oder Konto: Eines mit Gewicht 3 bekommt drei Anfragen für jede, die eines mit Gewicht 1 bekommt, schon über wenige Anfragen gleichmäßig. Eines, das fehlschlägt, wird übersprungen, solange es pausiert, und die anderen teilen sich seine Anfragen; ein Gespräch bleibt dort, wie „Bleibt“ es sagt.",
|
||||
|
||||
@@ -797,6 +797,7 @@ function routingPage(part) {
|
||||
free: ["Free first", "Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused."],
|
||||
cheap: ["Cheapest first", "Requests go to the member whose model costs least now, by its price a million tokens in and out at this hour — a vendor's peak hours count double where it bills them so, as DeepSeek and Ollama Cloud do — and the cheaper cache read when two cost the same; those that cost the same keep their listed order, and one with no known price goes last."],
|
||||
expiring: ["Free quota by expiry", "Free quota by expiry: the accounts on a free plan, or whose model costs nothing there, go first, the one whose free quota is lost soonest first — at its next reset, or when its credits expire if sooner; once it is used up, the next. A paid one takes requests only when no free one has quota left, the paid as Smart orders them."],
|
||||
fit: ["Small context first", "Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out."],
|
||||
fast: ["Speed first", "Requests go to the one that has answered this model fastest lately, by its time to the first token and how fast it writes; those within a tenth of each other keep their listed order. One not measured lately gets one request in five, so it is measured again, and one that fails is passed over while it rests."],
|
||||
};
|
||||
// modeOf: a routing's name and what it does, a JS gateway plugin's
|
||||
@@ -1065,6 +1066,12 @@ function routingPage(part) {
|
||||
|| t("Free quota by expiry: {who} has free quota left, so it's spent before any paid one.", { who: w });
|
||||
return t("Free quota by expiry: no free one has quota left, so {who}, which is paid for, is next.", { who: w });
|
||||
}
|
||||
case "fit":
|
||||
// Small context first (routes.SmallFirst): its model's window, as
|
||||
// the gateway read it for this request (Weighed.context)
|
||||
if (f.context) return restedTo(t("its {n} context window is the smallest that holds this request.", { n: ctxShort(f.context) }))
|
||||
|| t("Small context first: {who}'s {n} context window is the smallest that holds this request.", { who: w, n: ctxShort(f.context) });
|
||||
return t("Small context first: no member with a known context window can take this request, so {who} is next.", { who: w });
|
||||
case "cheap": {
|
||||
// Cheapest first (routes.Cheapest): its price now, as the gateway
|
||||
// read it for this request (Weighed.price)
|
||||
@@ -6361,7 +6368,7 @@ function routingPage(part) {
|
||||
// a group may also be routed by hand: every request to the member the
|
||||
// user picks on its card (provider.Manual, #317) — a provider's keys can't
|
||||
// and by its members' weights, as a provider's keys are (#1910)
|
||||
const GROUP_ROUTE_OPTS = [...ROUTE_OPTS, ["cheap", "Cheapest first"], ["expiring", "Free quota by expiry"], ["weight", "By weight"], ["manual", "Manual"]];
|
||||
const GROUP_ROUTE_OPTS = [...ROUTE_OPTS, ["cheap", "Cheapest first"], ["expiring", "Free quota by expiry"], ["fit", "Small context first"], ["weight", "By weight"], ["manual", "Manual"]];
|
||||
const AFF_OPTS = [["", "Auto"], ["session", "Session"], ["turn", "Within a turn"], ["off", "Off"], ["strict", "Strict"]];
|
||||
// what one rate limited with quota left does then (provider.Sink), as in
|
||||
// a provider's editor (app.js SINKS)
|
||||
@@ -6426,6 +6433,7 @@ function routingPage(part) {
|
||||
fast: "Speed first: the member that answered fastest lately goes first, by its time to the first token and how fast it writes, each of its accounts or keys weighed on its own; those within a tenth keep their listed order, and one not measured lately gets one request in five, so it is measured again.",
|
||||
cheap: "Cheapest first: the member whose model costs least now goes first, by its price a million tokens in and out at this hour — so a model billed double in its vendor's peak hours, as DeepSeek's own API and Ollama Cloud's DeepSeek models are, goes behind a provider charging less then, and ahead of it off-peak. Those that cost the same keep their listed order; one with no known price goes last.",
|
||||
expiring: "Free quota by expiry: the accounts on a free plan, or whose model costs nothing there, go first, the one whose free quota is lost soonest first — at its next reset, or when its credits expire if sooner; once it is used up, the next. A paid one takes requests only when no free one has quota left, the paid as Smart orders them.",
|
||||
fit: "Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; a member whose window the request is longer than is left out. Members of one size go as Smart orders them, and one whose window isn't known goes last.",
|
||||
manual: "Manual: every request goes to the model you pick on the group's card, over its own accounts or keys; the others, and the rules, wait until you pick another — none takes over when it fails.",
|
||||
};
|
||||
// a group in the group, and a provider set to route other than Smart, is
|
||||
|
||||
@@ -26,7 +26,7 @@ const base = { members: ["a/sol", "b/flash", "c/luna"], ready: true, memberInfo:
|
||||
|
||||
const words = {
|
||||
en: { order: "In order", manual: "Manual", weight: "By weight", smart: "Smart", head: "Routing", edit: "Edit",
|
||||
names: ["Smart", "In order", "Until used up", "In turn", "Least used first", "Use before expiry", "Free first", "Speed first", "Cheapest first", "Free quota by expiry", "By weight", "Manual"],
|
||||
names: ["Smart", "In order", "Until used up", "In turn", "Least used first", "Use before expiry", "Free first", "Speed first", "Cheapest first", "Free quota by expiry", "Small context first", "By weight", "Manual"],
|
||||
tip: "How Auto routes: click to change it", saved: "Auto: Manual" },
|
||||
zh: { order: "按顺序", manual: "手动", weight: "按权重", smart: "智能", head: "路由", edit: "编辑",
|
||||
tip: "Auto 的路由方式:点击更改", saved: "Auto:手动" },
|
||||
@@ -140,7 +140,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await menu.locator(".pm-head").textContent(), w.head);
|
||||
const items = menu.locator(".pm-item");
|
||||
if (w.names) assert.deepEqual(await items.locator(".pm-name").allTextContents(), w.names);
|
||||
assert.equal(await items.count(), 12);
|
||||
assert.equal(await items.count(), 13);
|
||||
assert.deepEqual(await menu.locator('.pm-item[aria-checked="true"] .pm-name').allTextContents(), [w.order]);
|
||||
assert.equal(await page.locator(".rt-gedit").count(), 0, "opening the menu opens no editor");
|
||||
// the menu sits inside the window
|
||||
@@ -229,7 +229,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await btn.getAttribute("title"), words[lang].tip);
|
||||
await btn.click();
|
||||
await page.locator(".proto-menu").waitFor();
|
||||
assert.equal(await page.locator(".proto-menu .pm-item").count(), 12);
|
||||
assert.equal(await page.locator(".proto-menu .pm-item").count(), 13);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Small context first (routes.SmallFirst, a routing group's; yg6888 on X)
|
||||
// on the Routing page: a request's story says why the first went first in
|
||||
// the words of its model's context window, as the gateway's trace gives it
|
||||
// (Weighed.context): "Composer 2.5's 200K context window is the smallest
|
||||
// that holds this request". One with no known window says it is next. The
|
||||
// mode line says what Small context first does. In both engines and every
|
||||
// language.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const now = new Date();
|
||||
const ago = (minutes) => new Date(now.getTime() - minutes * 60e3).toISOString();
|
||||
const key = (who, more) => ({ id: who + "#k", provider: who, name: who, who, kind: "key", model: "composer-2.5", routing: "fit", ...more });
|
||||
|
||||
const scenes = {
|
||||
// the smallest window that holds it goes first, the 1M one after
|
||||
smallest: { order: [key("cursor", { context: 200000 }), key("codex", { context: 1000000 })] },
|
||||
// none with a known window: the listed first
|
||||
unknown: { order: [key("relay"), key("other")] },
|
||||
};
|
||||
|
||||
function serve(lang, scene) {
|
||||
const s = scenes[scene];
|
||||
const route = {
|
||||
id: 1, seq: 1, time: ago(1), agent: "codex", model: "composer-2.5", provider: s.order[0].provider, done: true, status: 200, ms: 900, tokens: 1200, order: s.order,
|
||||
tries: [{ id: s.order[0].id, model: "composer-2.5", start: ago(1), done: true, status: 200, ms: 900 }],
|
||||
};
|
||||
return async (request) => {
|
||||
const url = new URL(request.request().url());
|
||||
const json = (data) => request.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return request.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return request.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [{ id: "codex", name: "Codex", path: "/test/config.toml", fields: [] }], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/gateway/trace") {
|
||||
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
|
||||
return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: 1 }, routes: [route] });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], excluded: [], gateway: { running: true, window: true } });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await request.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
async function open(t, engine, lang, scene, width = 1100) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await browser.newPage({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await page.route("**/*", serve(lang, scene));
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
const req = page.locator(".rt-req").first();
|
||||
await req.waitFor();
|
||||
if (await req.getAttribute("aria-pressed") !== "true") await req.click();
|
||||
await page.locator(".rt-steps li.why").first().waitFor();
|
||||
// what a string says in lang, its {names} filled in; a language without
|
||||
// it would say it in English, which the i18n-keys test catches
|
||||
const say = (key, vars = {}) => page.evaluate(([lang, key, vars]) => {
|
||||
const s = (lang !== "en" && I18N[lang]?.[key]) || key;
|
||||
return s.replace(/\{(\w+)\}/g, (_, k) => vars[k] ?? `{${k}}`);
|
||||
}, [lang, key, vars]);
|
||||
return { page, errors, say, why: async () => (await page.locator(".rt-steps li.why").first().textContent()).trim() };
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
test(`${engine} ${lang}: the smallest that holds it says its window`, async (t) => {
|
||||
const { page, errors, say, why } = await open(t, engine, lang, "smallest");
|
||||
assert.equal(await why(), await say("Small context first: {who}'s {n} context window is the smallest that holds this request.", { who: "cursor", n: "200K" }));
|
||||
assert.equal((await page.locator(".rt-mode").textContent()).trim(),
|
||||
await say("Small context first: each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests; one whose window it is longer than is left out."));
|
||||
if (lang !== "en") assert.notEqual(await say("Small context first"), "Small context first", `${lang} names Small context first`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: no window known, the next`, async (t) => {
|
||||
const { errors, say, why } = await open(t, engine, lang, "unknown");
|
||||
assert.equal(await why(), await say("Small context first: no member with a known context window can take this request, so {who} is next.", { who: "relay" }));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2063,7 +2063,7 @@ func SaveGroup(g Group) error {
|
||||
if err := cleanDecisionGroup(&g, groupsIn(entries)); err != nil {
|
||||
return err
|
||||
}
|
||||
if g.Routing != Ordered && g.Routing != Rotate && g.Routing != LeastUsed && g.Routing != Pace && g.Routing != Weighted && g.Routing != FreeFirst && g.Routing != Fastest && g.Routing != Cheapest && g.Routing != Drain && g.Routing != FreeExpiring && g.Routing != Manual && !PluginRouting(g.Routing) {
|
||||
if g.Routing != Ordered && g.Routing != Rotate && g.Routing != LeastUsed && g.Routing != Pace && g.Routing != Weighted && g.Routing != FreeFirst && g.Routing != Fastest && g.Routing != Cheapest && g.Routing != Drain && g.Routing != FreeExpiring && g.Routing != SmallFirst && g.Routing != Manual && !PluginRouting(g.Routing) {
|
||||
g.Routing = ""
|
||||
}
|
||||
if !slices.Contains(Affinities, g.Affinity) {
|
||||
|
||||
@@ -58,6 +58,13 @@ const (
|
||||
// (routes.FreeExpiring; wowbbs on Discord: five check-in accounts of
|
||||
// WorkBuddy, MiniMax, Trae and Qoder in one group). A group's only.
|
||||
FreeExpiring = "expiring"
|
||||
// SmallFirst sends a request to the member with the smallest context
|
||||
// window that holds it, so the big ones are kept for long requests
|
||||
// (routes.SmallFirst; yg6888 on X: Composer's 200K and Grok 4.7's
|
||||
// 256K never answered in a group of 1M models under Smart). Members
|
||||
// too small are left out as under every routing (roomy). A group's
|
||||
// only: a provider's keys and accounts serve one window.
|
||||
SmallFirst = "fit"
|
||||
)
|
||||
|
||||
// FreePlan says whether an account's plan, as its vendor or plugin names
|
||||
|
||||
@@ -114,6 +114,9 @@ type Seat struct {
|
||||
// costs 0. Cheapest goes by them.
|
||||
Priced bool
|
||||
Cost, CacheCost float64
|
||||
// Window is its model's context window there, in tokens, 0 when not
|
||||
// known. SmallFirst goes by it.
|
||||
Window int
|
||||
}
|
||||
|
||||
// Strategy orders a pool.
|
||||
@@ -144,6 +147,9 @@ type Strategy struct {
|
||||
// trace then shows it. Only when set: pricing reads each provider's
|
||||
// model list and the user's prices.
|
||||
ByPrice bool
|
||||
// ByWindow: it weighs by Window, so the gateway reads each seat's
|
||||
// model's context window, and the routing trace then shows it.
|
||||
ByWindow bool
|
||||
}
|
||||
|
||||
var reg = struct {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Small context first (yg6888 on X) puts the seat whose model's context
|
||||
// window is smallest first, so a request that fits it leaves the big ones
|
||||
// for those only they hold (the gateway has left out every seat the
|
||||
// request is longer than, roomy). A window not known goes after every
|
||||
// known one; seats of one window go as Smart orders them (the sooner
|
||||
// renewal first); one all but used up still goes after those with room,
|
||||
// whatever its window.
|
||||
func TestSmallFirstOrdersByWindow(t *testing.T) {
|
||||
soon, later := time.Now().Add(2*time.Hour), time.Now().Add(72*time.Hour)
|
||||
seats := []Seat{
|
||||
{Key: "1m", Known: true, Window: 1_000_000},
|
||||
{Key: "unknown", Known: true},
|
||||
{Key: "256k-later", Known: true, Window: 256_000, Soon: []time.Time{later}},
|
||||
{Key: "200k-spent", Known: true, Window: 100_000, Used: 100},
|
||||
{Key: "256k-soon", Known: true, Window: 256_000, Soon: []time.Time{soon}},
|
||||
{Key: "200k", Known: true, Window: 200_000},
|
||||
}
|
||||
var got []string
|
||||
for _, i := range Apply(SmallFirst, "g", seats) {
|
||||
got = append(got, seats[i].Key)
|
||||
}
|
||||
want := []string{"200k", "256k-soon", "256k-later", "1m", "unknown", "200k-spent"}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("Small context first ordered %v, want %v", got, want)
|
||||
}
|
||||
if !SmallFirst.ByWindow || Builtin["fit"].Order == nil {
|
||||
t.Fatal("Small context first doesn't weigh windows or isn't registered as fit")
|
||||
}
|
||||
}
|
||||
@@ -618,6 +618,43 @@ var Cheapest = Strategy{ByPrice: true, Order: func(_ string, seats []Seat) []int
|
||||
return idx
|
||||
}}
|
||||
|
||||
// SmallFirst sends a request to the member whose model has the smallest
|
||||
// context window, so the big ones are kept for the requests only they
|
||||
// hold: the gateway leaves out, before asking, every member whose window
|
||||
// the request is longer than (roomy), so the first left is the smallest
|
||||
// that holds it. In Smart's order otherwise: a seat all but used up
|
||||
// still goes after those with room, one set to be used first still
|
||||
// first, and members of one window in Smart's order among themselves; a
|
||||
// window not known goes after every known one.
|
||||
var SmallFirst = Strategy{ByWindow: true, Order: func(pool string, seats []Seat) []int {
|
||||
idx := Smart.Order(pool, seats)
|
||||
rank := func(s Seat) (int, int) {
|
||||
g := 1
|
||||
switch {
|
||||
case seatTier(s) == 2:
|
||||
g = 2
|
||||
case s.Lead:
|
||||
g = 0
|
||||
}
|
||||
return g, s.Window
|
||||
}
|
||||
sort.SliceStable(idx, func(a, b int) bool {
|
||||
ga, wa := rank(seats[idx[a]])
|
||||
gb, wb := rank(seats[idx[b]])
|
||||
if ga != gb {
|
||||
return ga < gb
|
||||
}
|
||||
if wa == wb {
|
||||
return false
|
||||
}
|
||||
if wa == 0 || wb == 0 { // not known: after those known
|
||||
return wb == 0
|
||||
}
|
||||
return wa < wb
|
||||
})
|
||||
return idx
|
||||
}}
|
||||
|
||||
// sameCost: two prices within a millionth of each other, or of a cent a
|
||||
// million tokens, are the same price.
|
||||
func sameCost(a, b float64) bool {
|
||||
@@ -641,4 +678,5 @@ var Builtin = map[string]Strategy{
|
||||
provider.Cheapest: Cheapest,
|
||||
provider.Drain: Drain,
|
||||
provider.FreeExpiring: FreeExpiring,
|
||||
provider.SmallFirst: SmallFirst,
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ var zh = map[string]string{
|
||||
"cheapest first": "最便宜优先",
|
||||
"until used up": "用完再换",
|
||||
"free, soonest to expire": "免费且最快到期优先",
|
||||
"small context first": "小上下文优先",
|
||||
"manual": "手动",
|
||||
"smart": "智能",
|
||||
"stays the session": "整个会话保持",
|
||||
|
||||
@@ -68,7 +68,7 @@ func (m model) listedMembers(g provider.Group) ([]string, int) {
|
||||
return on, len(g.Members) - len(on)
|
||||
}
|
||||
|
||||
var routings = []string{"", provider.Ordered, provider.Rotate, provider.LeastUsed, provider.Pace, provider.Weighted, provider.FreeFirst, provider.Fastest, provider.Cheapest, provider.Drain, provider.FreeExpiring, provider.Manual}
|
||||
var routings = []string{"", provider.Ordered, provider.Rotate, provider.LeastUsed, provider.Pace, provider.Weighted, provider.FreeFirst, provider.Fastest, provider.Cheapest, provider.Drain, provider.FreeExpiring, provider.SmallFirst, provider.Manual}
|
||||
|
||||
func routingName(v string) string {
|
||||
switch v {
|
||||
@@ -92,6 +92,8 @@ func routingName(v string) string {
|
||||
return tr("until used up")
|
||||
case provider.FreeExpiring:
|
||||
return tr("free, soonest to expire")
|
||||
case provider.SmallFirst:
|
||||
return tr("small context first")
|
||||
case provider.Manual:
|
||||
return tr("manual")
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Package rotation is the routings a provider or group can be set to
|
||||
// besides Smart: In order, Until used up, In turn, Least used first,
|
||||
// Use before expiry, By weight, Free first, Speed first and Cheapest first (a
|
||||
// group's). While a provider or group is routed by one, it
|
||||
// stays on.
|
||||
// Use before expiry, By weight, Free first, Speed first, and a group's
|
||||
// Cheapest first, Free quota by expiry and Small context first. While a
|
||||
// provider or group is routed by one, it stays on.
|
||||
//
|
||||
// It is the first consumer of the gateway's router strategy point (P3 of
|
||||
// docs/subsystems/plugin-runtime.md): Apply registers internal/routes'
|
||||
|
||||
@@ -155,7 +155,7 @@ c7070237e2a6b86e43a2a22c43d72a8a6a36e00c7f9877028d5a7fbbeceaafcb docs/ja/routin
|
||||
ae657d3db2c4cfacb886a228bc97c3c074d83d3bed441ad60c01931325e3fe44 docs/ja/shelley.html
|
||||
f2f8e870c8fd1f14483d223ad834b1c99b64c6e39a02b7bd0b12ab74e239624c docs/ja/siliconflow.html
|
||||
b000018f7903dfb44f7bff6d469a6bd5ec13ba9528893bf409bdde638589c630 docs/ja/snow-cli.html
|
||||
962395e92df0d77c935340c4734e85f3aa2665632f84152421ab8af5532aa73f docs/ja/start.html
|
||||
cd41e22aca4ad289e5b3dacd633fba2cb308e50238218d46b73e5f992c1e4869 docs/ja/start.html
|
||||
1ea5845f140e9e6aa932120bec2f1ff7bf3731603f39996948f561b1a1f52a7f docs/ja/stepcode.html
|
||||
1eb86470ebe9f83f402d7d77ee8cd51e29f41b5ba4aed2da16b6947c0eee6bd2 docs/ja/stepfun.html
|
||||
9964db876b8f2f16d2c6ea36921c2ad888d7794fac33a447a28bffa5ca1d4e83 docs/ja/subscriptions.html
|
||||
@@ -230,7 +230,7 @@ cbf3a16eee9a07f5c1f5dda30b26787d574a79189fbe8a26ed6088aa9c962d88 docs/routing-g
|
||||
9c22ec06ed58767bdb661e8ccb6bf324ee42d94ef74fe27e6a05b53885316d3d docs/shelley.html
|
||||
6f431de880c17c89b081bb424ea551ba48f1502b11c656c6af28c222acf7419e docs/siliconflow.html
|
||||
3468488643bd5e20c6ef6145e1b163df83eda6ee1c85ab08f2a316cd0e0058ec docs/snow-cli.html
|
||||
a5ae49b1881edff736719cfed7c37b9485eaa1648aad9c3388d279ecc4b570de docs/start.html
|
||||
67a2909226af4d3e7fa195f9c0b5389740fa943012efda0821bd9b06229b31a3 docs/start.html
|
||||
48ac24aec6e88393e743659432c8edbf6b99a3ede8cee44426c4d728353b9892 docs/stepcode.html
|
||||
1969c326de53bf8c97ed5580516edb8a5a6fa5375a74494abdfc913298126284 docs/stepfun.html
|
||||
79eb1159590a6d4c5d1a1df8a2a6a7b158357ba2d64f62bdbf21a1bf8276e021 docs/subscriptions.html
|
||||
@@ -355,7 +355,7 @@ b2218124e8755dad24e20ecccf7938c9b30e8ae51de574ce46c1514d871ce0c4 docs/zh/routin
|
||||
1d4b1922da7504bbcf8f6c6b8a77d3688fc877d0a1188c9d3d3d3f9b29deafc6 docs/zh/shelley.html
|
||||
57da389d7a92c3ae1da447f06fb63f4437f16a2c775476f9e25eba40391e41ad docs/zh/siliconflow.html
|
||||
bb734095a02534238e82541efac317b6eab7805e87de9e666245212ea5562396 docs/zh/snow-cli.html
|
||||
329b512cdd19162166fe01eb063a8e5ab2069ef6613a22ddc4479c047ad82595 docs/zh/start.html
|
||||
ba6affc2c895059265a4d76be1d7b3f26356c1144c1f52b207692a253dc1a6c6 docs/zh/start.html
|
||||
f8a9f30aabfa53592dd5e548480763776a2d4913175eccd3fd6d107858a0d0c0 docs/zh/stepcode.html
|
||||
dc7be40c877df9ea7ef2c9ccc6c829bdd217d3f74a2ebdf0c54a848da0cba82f docs/zh/stepfun.html
|
||||
b98fe5e40042853057e726642fae823183b85b27ead65de68705a13e0ab4a318 docs/zh/subscriptions.html
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
<tr><td>重み順 <code>weight</code></td><td>グループ編集画面で各モデルの横に設定した重み(1〜1000、未設定は 1)に応じてリクエストを分けます。重み 3 のモデルは重み 1 のモデルが 1 件受けるごとに 3 件受け、まとめてではなく均等に散らします。各モデルは自分のプロバイダーのルーティングで自分のアカウントやキーを使い、グループ内のグループは 1 つとして数えます。失敗して休んでいるものはその回から外れ、失敗したときは次のモデルが代わりに答えます。</td></tr>
|
||||
<tr><td>速度優先 <code>fast</code></td><td>このモデルに最近いちばん速く応答したメンバー、アカウント、キーが先です。最初のトークンまでの時間と出力の速さで比べ、新しい応答ほど重く数えます。差が 1 割以内のものは並び順のままです。1 時間測っていないものには 5 件に 1 件を回すので、一度遅かったチャネルもまた試されます。失敗して休んでいるものは最後です。測るのはストリーミングの応答だけで、再起動すると測り直します。</td></tr>
|
||||
<tr><td>最安優先 <code>cheap</code></td><td>ルーティンググループのみ。いまモデルが最も安いメンバーが先です。Usage が数えるのと同じく、この時間帯の入力・出力 100 万トークンあたりの価格で比べます:自分で設定した価格、なければ定価に、プロバイダの価格倍率と時間帯倍率をかけたもの。DeepSeek 公式 API、Command Code と OpenCode Go の DeepSeek モデルはピーク時間帯(平日 UTC 01:00–04:00 と 06:00–10:00)に、Ollama Cloud の DeepSeek V4.1 Flash と V4 Pro は自社のピーク時間帯(平日 UTC 12:00–18:00、それ以外は半額)に 2 倍になるので、2 つのプロバイダにある同じ DeepSeek モデルはその時間に安い方へ送られます。同じ価格のものは順番どおり、価格が分からないものは最後です。</td></tr>
|
||||
<tr><td>小さいコンテキスト優先 <code>fit</code></td><td>ルーティンググループのみ。各リクエストは、それが収まる中でコンテキストウィンドウが最も小さいメンバーに送られ、大きいものは長いリクエストのために残します。リクエストがウィンドウより長いメンバーは、どのルーティングでも同じく外します。同じ大きさのメンバーはスマートの順で、ウィンドウが分からないものは最後です。</td></tr>
|
||||
</table></div>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>維持</th><th>会話が、応答したアカウントやキーに留まる期間</th></tr>
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
<tr><td>By weight <code>weight</code></td><td>Each model takes its share of the requests by the weight set beside it in the group editor (1 to 1000, 1 if unset): one weighing 3 takes three for every one a model weighing 1 takes, spread out rather than in bursts. Each model is tried whole over its own accounts or keys, as its provider routes them, and a group in the group counts as one. One resting after a failure leaves the round; the next model is the fallback when one fails.</td></tr>
|
||||
<tr><td>Speed first <code>fast</code></td><td>The member, account or key that answered this model fastest lately: the time to its first token and how fast it writes, newer answers counting more. Those within a tenth of each other keep their order. One not measured in the last hour gets one request in five, so a channel that was slow once is tried again; one resting after a failure goes last. Only streamed replies are measured, and a restart measures again from scratch.</td></tr>
|
||||
<tr><td>Cheapest first <code>cheap</code></td><td>Groups only. The member whose model costs least now, by its price a million tokens in and out at this hour as Usage counts it: your own price for it, else its list price, at the provider’s price rate and rate windows. DeepSeek’s own API, Command Code’s and OpenCode Go’s DeepSeek models cost double in their peak hours (weekdays 01:00–04:00 and 06:00–10:00 UTC), and Ollama Cloud’s DeepSeek V4.1 Flash and V4 Pro in its own (weekdays 12:00–18:00 UTC, half price the rest of the time), so a DeepSeek model listed on two providers goes to the one cheaper at that hour. Members that cost the same keep their order; one with no known price goes last.</td></tr>
|
||||
<tr><td>Small context first <code>fit</code></td><td>Groups only. Each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests. A member whose window the request is longer than is left out, as under every routing. Members of one size go as Smart orders them, and one whose window isn’t known goes last.</td></tr>
|
||||
</table></div>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>Stays</th><th>How long a conversation stays with the account or key that answered it</th></tr>
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
<tr><td>按权重 <code>weight</code></td><td>每个模型按群组编辑器里它旁边设的权重(1 到 1000,不设为 1)分得请求:权重 3 的模型每拿三个,权重 1 的拿一个,均匀穿插而不是成批。每个模型按它自己提供方的路由用自己的账号或 Key,群组里的群组算一个成员。失败后歇着的那个退出这一轮;一个失败时,下一个模型接上。</td></tr>
|
||||
<tr><td>速度优先 <code>fast</code></td><td>最近回答这个模型最快的成员、账号或 Key 先用:看首字时间和输出速度,越新的回答算得越重。相差不到一成的保持原来的顺序。一小时内没测过的每五个请求分到一个,慢过一次的渠道还会再试;失败后歇着的排最后。只测流式回复,重启后重新测。</td></tr>
|
||||
<tr><td>最便宜优先 <code>cheap</code></td><td>仅限路由组。此刻模型最便宜的成员先用,按 Usage 计费的方式算这个时段每百万输入、输出 token 的价格:你自己设的价格,否则用标价,再乘以提供方的价格倍率和分时倍率。DeepSeek 官方 API、Command Code 和 OpenCode Go 的 DeepSeek 模型在高峰时段(工作日 UTC 01:00–04:00 和 06:00–10:00)双倍计价,Ollama Cloud 的 DeepSeek V4.1 Flash 和 V4 Pro 则按它自己的高峰时段(工作日 UTC 12:00–18:00,其余时间半价),所以同一个 DeepSeek 模型挂在两个提供方上时,会交给这个时段更便宜的那个。价格相同的保持原来的顺序;不知道价格的排最后。</td></tr>
|
||||
<tr><td>小上下文优先 <code>fit</code></td><td>仅限路由组。每个请求交给能装下它、上下文窗口最小的成员,大窗口的留给长请求。窗口比请求短的成员不参与,和其他路由方式一样。窗口一样大的按智能的顺序,窗口未知的排最后。</td></tr>
|
||||
</table></div>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>会话保持</th><th>会话在回答过它的账号或 Key 上留多久</th></tr>
|
||||
|
||||
@@ -129,6 +129,7 @@ A group is several models, from one provider or many, that an agent picks as one
|
||||
| By weight `weight` | Each model takes its share of the requests by the weight set beside it in the group editor (1 to 1000, 1 if unset): one weighing 3 takes three for every one a model weighing 1 takes, spread out rather than in bursts. Each model is tried whole over its own accounts or keys, as its provider routes them, and a group in the group counts as one. One resting after a failure leaves the round; the next model is the fallback when one fails. |
|
||||
| Speed first `fast` | The member, account or key that answered this model fastest lately: the time to its first token and how fast it writes, newer answers counting more. Those within a tenth of each other keep their order. One not measured in the last hour gets one request in five, so a channel that was slow once is tried again; one resting after a failure goes last. Only streamed replies are measured, and a restart measures again from scratch. |
|
||||
| Cheapest first `cheap` | Groups only. The member whose model costs least now, by its price a million tokens in and out at this hour as Usage counts it: your own price for it, else its list price, at the provider’s price rate and rate windows. DeepSeek’s own API, Command Code’s and OpenCode Go’s DeepSeek models cost double in their peak hours (weekdays 01:00–04:00 and 06:00–10:00 UTC), and Ollama Cloud’s DeepSeek V4.1 Flash and V4 Pro in its own (weekdays 12:00–18:00 UTC, half price the rest of the time), so a DeepSeek model listed on two providers goes to the one cheaper at that hour. Members that cost the same keep their order; one with no known price goes last. |
|
||||
| Small context first `fit` | Groups only. Each request goes to the member with the smallest context window that holds it, so the big ones are kept for long requests. A member whose window the request is longer than is left out, as under every routing. Members of one size go as Smart orders them, and one whose window isn’t known goes last. |
|
||||
|
||||
| Stays | How long a conversation stays with the account or key that answered it |
|
||||
| --- | --- |
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user