mirror of
https://github.com/THU-MAIC/OpenMAIC.git
synced 2026-10-18 05:40:25 +08:00
The one-shot generateClassroom path (skill API) resolved the model once
with `resolveModel({ stage: 'generate-classroom' })` and bound that
single `languageModel` into one `sceneAiCall` closure shared by every
scene-content and scene-actions call (and the classroom `aiCall` shared
by outline + agent profiles). As a result, none of the `MODEL_ROUTES`
entries for `scene-content`, `scene-content:<type>`
(slide/quiz/interactive/pbl), `scene-actions`, or `agent-profiles` had
any effect on this path — the browser UI already routes each stage
independently via the /api/generate/* endpoints, but the one-shot API
did not.
Resolve the model per stage instead, mirroring the browser UI:
- scene-content routes via the composite key `scene-content:<type>`,
falling back to the base `scene-content` route (same resolution as
/api/generate/scene-content). Interactive widget sub-types are not
split, only the four core scene types.
- scene-actions routes via the `scene-actions` stage.
- agent-profiles routes via the `agent-profiles` stage (matches
/api/generate/agent-profiles).
- outline generation keeps using the classroom model, unchanged.
Each stage is resolved lazily and only when a route is actually
configured, so unrouted deployments reuse the classroom model at zero
extra cost. A route that fails to resolve (e.g. an unknown provider)
degrades to the classroom model with a warning, never aborting
generation — the same handling already used for
`web-search-query-rewrite`.
This also fixes a latent bug on this path: PBL scene content generation
needs the resolved `LanguageModel` object (generatePBLSceneContent
drives its own LLM calls through it, not the aiCall closure), but the
call never passed it, so PBL scenes silently returned null and were
skipped. The browser UI already passes it; now the one-shot path does
too — and it also forwards the route's thinking config, so a
`scene-content:pbl` route with a `thinking` block is honored (not just
the model).
The `generate-classroom-scene` telemetry/billing label is preserved on
all scene calls to avoid changing existing logging and accounting;
agent-profiles keeps the `generate-classroom` label.
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>