Commit Graph
2 Commits
Author SHA1 Message Date
yetone 8d95ebc8c3 provider: Bailian Token Plan is a preset of its own, with its decision model for routing groups; the Qwen AI platform's decision model too, and Bailian's shows Bailian's icon (#1506, IamMiao)
Alibaba sells two Token Plans, both with sk-sp- keys, and a key works only
on its own host. qwen-token-plan is the Qwen AI platform's
(token-plan.maas.qianwenaiapi.com), but its website and keys links pointed
at Bailian's console. Bailian's own plan
(token-plan.cn-beijing.maas.aliyuncs.com) had no preset.

What changed:
- presets: new bailian-token-plan (chat /compatible-mode/v1, Anthropic
  /apps/anthropic, decide on /compatible-mode/v1/systemone, models from the
  docs' list, shared with qwen-token-plan as alibabaPlanModels).
  qwen-token-plan's links now point at the Qwen AI platform. New
  qwen-decision for Qwen's pay-as-you-go decision model at
  maas.qianwenaiapi.com/compatible-mode/v1/systemone. bailian-decision shows
  the Bailian icon instead of Qwen's.
- decide: bailianDecides also matches the bare maas.qianwenaiapi.com host.
  A chat preset that also decides on a Bailian/Qwen host (bailianApart)
  lists decision-model-preview as its only decision model, so it is offered
  for routing groups and never given to an agent as a chat model.
- gateway: dashScope() covers bailian-token-plan and maas.qianwenaiapi.com.
- CLI help, docs/reference.md and the import docs (en, zh, ja) name the new
  preset.

Usage: neither plan's docs give a usage or quota API; the remaining quota
is only on the console (百炼控制台 Token Plan > 我的订阅, Qwen 工作台
token-plan/individual), which needs a browser session. So no usage card is
added. An exhausted plan's 429 insufficient_quota is already read as out of
credit.

Not tried against the real API: no Bailian or Qwen key was available. The
stand-in is an httptest server copying the docs' systemone curl (Bearer
sk-sp-, model decision-model-preview) and its error table (401 on a wrong
key, 422 on a bad body). qwen-decision sends "Authorization: Bearer <key>";
the Qwen doc's curl shows the bare key, which is untested.

Run:
- go test -tags nogui -count=1 ./... (temp HOME)
- TestBailianTokenPlan, TestQwenDecisionPreset and TestDashScopeHosts fail
  with the old decide.go and gateway.go swapped in
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on .
  internal/provider, internal/gateway, internal/gui
- GUI: system-one, add-sheet, gateway-decide-info, routing-kind tests in
  chromium and webkit (20 pass)
2026-10-10 21:14:38 +08:00
yetone 2de57456e6 gateway: a Qwen request for one JSON body is asked streamed and given back whole, so a routing group's classifier on the Qwen Token Plan works (ZekeXiao on X)
DashScope (Model Studio / Bailian, incl. the Qwen Token Plan) turns a
thinking model's non-streaming call away with 400 "parameter.enable_thinking
must be set to false for non-streaming calls". A routing group's classifier
asks its model for one body (stream:false), so qwen-token-plan's models
failed as the decision model ("400 · 失败" in the routing log).

A non-streaming Chat request to a DashScope provider (the qwen, qwen-cn and
qwen-token-plan presets, or a dashscope*/.maas.aliyuncs.com/
.maas.qianwenaiapi.com host) is no longer relayed as is: it goes through the
translator on Chat, which always asks streamed and collects the reply into
one body. Thinking is left as the model does it, rather than forcing
enable_thinking:false, which always-thinking models refuse. Other vendors
are unchanged (the test checks one).

The ask for per-model custom params on the decision model is not added:
the error was magpie's request shape, which is now right for every client.

Run: TestDashScopeWholeAskedStreamed fails on the old code with the
DashScope 400 and passes now; go test ./... green; gofmt; go vet for
darwin, linux and windows.
2026-10-10 17:39:56 +08:00