JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(tui): multi-model not allowed to config as default model
douran382f7f81b93a
diff --git a/jiuwenclaw/cli/src/core/commands/builtins/model.ts b/jiuwenclaw/cli/src/core/commands/builtins/model.tsindex d757f3f44b..b121f88bda 100644--- a/jiuwenclaw/cli/src/core/commands/builtins/model.ts+++ b/jiuwenclaw/cli/src/core/commands/builtins/model.ts@@ -14,6 +14,13 @@ export interface ModelListPayload {models?: ModelMeta[];}+/** Reserved keys under config.yaml `models` for multimodal profiles; configure via /config, not via /model switch */+const RESERVED_MULTIMODAL_MODEL_KEYS = new Set(["video", "audio", "vision"]);++export function isReservedMultimodalModelKey(name: string): boolean {+ return RESERVED_MULTIMODAL_MODEL_KEYS.has(name.trim().toLowerCase());+}+export function createModelCommand(): SlashCommand {return {name: "model",@@ -84,7 +91,22 @@ export function createModelCommand(): SlashCommand {ctx.addItem(addInfo(ctx.sessionId, "No models configured", "m"));return;}- const items = models.map((m, i) => {+ const skipped = models.filter((m) => isReservedMultimodalModelKey(m));+ const selectable = models.filter((m) => !isReservedMultimodalModelKey(m));+ if (skipped.length > 0) {+ ctx.addItem(+ addInfo(+ ctx.sessionId,+ "video, audio, and vision are not offered as the default chat model here (multimodal-only). To configure them, use /config edit → Vision / Audio / Video, or /config set on keys such as vision_model, audio_model, video_model.",+ "m",+ ),+ );+ }+ if (selectable.length === 0) {+ ctx.addItem(addInfo(ctx.sessionId, "No switchable models in list", "m"));+ return;+ }+ const items = selectable.map((m, i) => {const isCurrent = m === current;return {label: String(i + 1),@@ -92,7 +114,7 @@ export function createModelCommand(): SlashCommand {};});ctx.addItem(- addInfo(ctx.sessionId, `Available models (${models.length} total)`, "m", {+ addInfo(ctx.sessionId, `Available models (${selectable.length} total)`, "m", {view: "list",title: "Switch Model",items,@@ -101,6 +123,16 @@ export function createModelCommand(): SlashCommand {return;}+ if (isReservedMultimodalModelKey(value)) {+ ctx.addItem(+ addError(+ ctx.sessionId,+ "Cannot use /model to select video, audio, or vision as the default chat model. Configure multimodal APIs in /config edit (Vision / Audio / Video) or /config set (e.g. vision_model, audio_model, video_model).",+ ),+ );+ return;+ }+// Switch to specific modelconst payload = await ctx.request<{current?: string;diff --git a/jiuwenclaw/cli/src/ui/app-screen.ts b/jiuwenclaw/cli/src/ui/app-screen.tsindex 12dccfc91f..bc8340f9f7 100644--- a/jiuwenclaw/cli/src/ui/app-screen.ts+++ b/jiuwenclaw/cli/src/ui/app-screen.ts@@ -25,7 +25,10 @@ import {import { CommandService, parseSlashCommand } from "../core/commands/CommandService.js";import { addError, addInfo } from "../core/commands/helpers.js";import type { FileAttachment } from "../core/protocol.js";-import type { ModelListPayload } from "../core/commands/builtins/model.js";+import {+ type ModelListPayload,+ isReservedMultimodalModelKey,+} from "../core/commands/builtins/model.js";import type { SessionListPayload, SessionMeta } from "../core/commands/builtins/resume.js";import type { ConfigItemSchema } from "../core/commands/builtins/config.js";import { buildModeAutocompleteItems } from "../core/commands/builtins/mode.js";@@ -870,7 +873,24 @@ export class AppScreen implements Component, Focusable {return;}- const items = models.map((m, i) => {+ const skipped = models.filter((m) => isReservedMultimodalModelKey(m));+ const selectable = models.filter((m) => !isReservedMultimodalModelKey(m));+ if (skipped.length > 0) {+ this.state.addItem(+ addInfo(+ snapshot.sessionId,+ "video, audio, and vision are not offered as the default chat model here (multimodal-only). To configure them, use /config edit → Vision / Audio / Video, or /config set on keys such as vision_model, audio_model, video_model.",+ "m",+ ),+ );+ }+ if (selectable.length === 0) {+ this.modelList = null;+ this.state.addItem(addInfo(snapshot.sessionId, "No switchable models in list", "m"));+ return;+ }++ const items = selectable.map((m, i) => {const isCurrent = m === current;return {label: `${i + 1}. ${m}${isCurrent ? " (current)" : ""}`,@@ -888,7 +908,7 @@ export class AppScreen implements Component, Focusable {this.modelList = null;this.tui.requestRender();};- this.modelList = { list, models, current };+ this.modelList = { list, models: selectable, current };this.tui.requestRender();} catch (error) {const message = error instanceof Error ? error.message : String(error);@@ -901,6 +921,17 @@ export class AppScreen implements Component, Focusable {if (!modelName) {return;}+ if (isReservedMultimodalModelKey(modelName)) {+ this.modelList = null;+ this.state.addItem(+ addError(+ this.state.getSnapshot().sessionId,+ "Cannot select video, audio, or vision as the default chat model. Configure multimodal APIs in /config edit (Vision / Audio / Video) or /config set (e.g. vision_model, audio_model, video_model).",+ ),+ );+ this.tui.requestRender();+ return;+ }this.modelList = null;try {const payload = await this.state.request<{