Commit Graph
12 Commits
Author SHA1 Message Date
Loongphy 76c3b7201b feat: raise max output tokens to 128K (documented upstream ceiling)
Aliyun Model Studio (the upstream behind Qoder's CN catalog) documents
Max Output Length = 131072 for every model we expose, in both normal and
thinking modes (thinking chain alone goes to 262144):
  qwen3.8-max/flash, qwen3.7-max/plus/flash — all 131072.

The previous 32768 default (copied from qodercli's conservative 32e3) used
only 1/4 of the supported output budget. That truncates reasoning chains in
thinking mode (where the chain counts against output) and risks cutting long
generations / compaction summaries. qodercli caps its own UI at 65536, still
below the documented ceiling.

- models.ts: introduce MAX_OUTPUT_TOKENS = 131072 as the single source of
  truth; all 24 staticModels entries + the lazy-loaded CN entry now reference
  it. Remove the dead max_output_tokens field from the CN placeholder entry.
- stream.ts: maxTokens defaults to MAX_OUTPUT_TOKENS; still capped lower by
  options.maxTokens (e.g. pi compaction passes 40000).

Verified against the real CN endpoint: max_tokens=131072 returns 200 / stop
(accepted, not rejected); an xhigh reasoning run completes with
finish_reason=stop (not truncated). Field placement + reasoning_effort send
also confirmed working in the same request.
2026-08-28 19:36:59 +08:00
Loongphy 112da4deaf refactor: drop dead max_output_tokens, simplify maxTokens to 32K + pi cap
Qoder's /model/list catalog never returns max_output_tokens (the field does
not exist on any entry — only max_input_tokens is present), so the per-model
lookup `entry.max_output_tokens || 32768` was dead code that always fell back
to the 32768 literal.

- models.ts: remove max_output_tokens from QoderModelEntry; maxTokens is now a
  flat 32768 (matches qodercli's 32e3 fallback).
- stream.ts: remove the now-unused maxOutputTokens variable and its always-true
  branch; maxTokens = 32768, capped lower only by options.maxTokens (e.g. pi
  compaction passes 40000). pi-ai's maxTokens setting still has an outlet.
- stream.ts fallback modelConfig: drop the dead max_output_tokens: 32768 field.

qodercli does conditionally send max_tokens (user setting → generation config
→ 32K fallback), but the field is not required by the upstream API. Keeping it
gives pi-ai's options.maxTokens a place to flow through.
2026-08-28 19:07:16 +08:00
Loongphy 88cf414a8e feat(cn): map Qoder thinking_config to pi thinkingLevelMap for the picker
The catalog API returns each model's supported thinking efforts
(thinking_config.enabled.efforts, e.g. low/medium/xhigh for qwen3.8), but the
provider never populated Model.thinkingLevelMap, so pi's getSupportedThinkingLevels
hid xhigh/max (they require a non-undefined map entry) and the picker topped out
at "high" even for models that support xhigh.

Parse thinking_config at catalog fetch time and build the map:

- effort-based models (qwen3.8-max/flash, DeepSeek, GLM): each supported
  effort maps to its same-named pi level; unsupported levels pin to null
  (hidden). xhigh is now exposed. "off" is selectable when the catalog also
  advertises a "disabled" option.
- toggle-only models (qwen3.7-max/plus: enabled/disabled, no efforts):
  every pi level is exposed and maps to "enabled" so picking any level turns
  thinking on; "off" selectable when "disabled" is advertised.
- models without thinking_config (qwen3.7-flash): no map, pi falls back to its
  default level set.

Qoder effort keys are already pi level names (low/medium/high/xhigh/max), so
the mapping is by identity — no translation table.

This is display-layer only: it fixes which thinking levels the picker shows.
Sending the chosen effort upstream is a separate change that needs the exact
request field from a qoder-cli capture; the map values ("low"/"xhigh"/
"enabled"/"disabled") are placeholders that will be mapped to the request
shape once confirmed.
2026-08-28 17:27:07 +08:00
Loongphy cc461cd145 refactor: drop redundant max_input_tokens, default context fallback to 200K
max_input_tokens (180K) was only used to seed the context window before
context_config options overrode it. Every live CN model exposes selectable
contexts (200K/400K/1M) whose smallest option already exceeds 180K, so the
seed only ever acted as a redundant floor and was never the final value.

- updateQoderModelsCache: derive contextWindow from the largest
  context_config option directly; fall back to 200K when no context_config is
  present (was 180K via max_input_tokens).
- staticCnModels: the Auto entry (the no-context fallback) now uses 200K too,
  matching the dynamic fallback; its description no longer references the
  stale 180K live-catalog note.
2026-08-28 10:11:37 +08:00
Loongphy b462207447 feat(cn): expose upstream display_name as model id, drop key mapping tables
The CN model picker used to translate Qoder's internal keys (qfmodel,
qmodel_latest, ...) into hardcoded "friendly" ids (qwen3.6-flash, ...) via a
manual mapping table, with the display label hardcoded alongside. Both
sides rotted independently of upstream: when Qoder upgraded qfmodel to
Qwen3.8-Flash the label stayed "Qwen 3.6 Flash", and new keys (qmodel_38max,
q37fmodel) had no entry so their raw key leaked into the picker as the id.

The catalog API already returns every key with its display_name, so the
mapping table duplicates data the server provides and can only ever be stale.

Rework: use the upstream display_name (whitespace-stripped) directly as the
pi-visible Model.id, and read the request-time upstream key back from the
cached model config at send time. No key<->friendlyId table is needed.

- cosy.ts: remove qoderCNFriendlyModels, getQoderCNDirectModel,
  getQoderCNFriendlyModelInfo, toQoderCNFriendlyModel, prettifyQoderCNModelName.
  Add toQoderCNModelId(display) = display with whitespace stripped.
- models.ts: updateQoderModelsCache now sets CN model id =
  toQoderCNModelId(display_name); the original key is still stored in configs
  (keyed by both key and id) and read back via getCachedModelConfig. Simplify
  the CN fallback in getCachedModelConfig (drop the stale reasoning set).
  staticCnModels ids/names rewritten to the display_name form.
- stream.ts: the upstream key comes from modelConfig.key (the cached entry)
  instead of a reverse-lookup table; falls back to model.id for the
  international site, which already uses the key as id.
- index.ts: modelsForProvider no longer re-maps CN models through a friendly
  transform — the cached/static ids are already the display name.

Trade-off: a renamed/upgraded model changes its id, so a previously saved
default model may no longer resolve after an upstream rename and the user
reselects. This is expected: users should learn about new models. This is
accepted.

Tests updated for the new contract; e2e against the live CN catalog confirms
id=Qwen3.8-Flash resolves to send key=qfmodel with no mapping table.
2026-08-28 08:16:36 +08:00
het-e2mandGitHub 939862023b feat: add latest Qoder frontier models 2026-07-27 14:18:18 +05:30
Simon Shi 55e87cbdef fix: stop adding auto as Qoder model fallback 2026-07-22 19:42:46 +09:00
Simon Shi 43448f0cc0 feat: default to maximum context size 2026-07-20 20:55:09 +08:00
温习江湖andGitHub 2b2f427628 Support Qoder CN (#4)
* feat(qoder-cn): add region endpoints and model catalog

* feat(qoder-cn): add separate provider auth and streaming

* docs: document Qoder CN provider
2026-06-26 14:42:36 +08:00
Simon Shi bcaa66091e fix: route PAT login through pi LoginDialog callbacks
The custom ctx.ui.custom login menu stole focus from pi's built-in
LoginDialog, so onPrompt never received keystrokes and PAT login
silently failed with 'No API key found'. Drive login via the provided
onPrompt/onAuth/onProgress callbacks instead, and drop login-ui.ts and
the now-unused pi-tui dependency. Also clears remaining lint warnings
by removing any-casts in models/oauth/stream/transform.
2026-06-16 13:39:16 +08:00
Simon Shi c9413961d2 fix: compute max contextWindow dynamically from context_config 2026-06-16 13:38:52 +08:00
Simon Shi dd8c313984 feat: init pi-provider-qoder plugin with oauth, signature and WAF bypass 2026-06-16 13:38:48 +08:00