From cafed44daf6ea016704c19d49587aafb5d5c14e3 Mon Sep 17 00:00:00 2001 From: Xingkai98 Date: Sat, 14 Nov 2026 11:18:49 +0800 Subject: [PATCH 1/4] feat: collapse the vLLM-Omni presets into one local service The seven per-stage presets each carried a protocol of their own, so a multi-stage vLLM-Omni server needed seven separate connections. One preset now maps every stage to its endpoints -- /chat/completions, /images/generations, /images/edits, /videos, /audio/speech, /audio/transcriptions, /images/segmentations and /videos/segmentations -- with http://127.0.0.1:8000/v1 as the default connection. Each stage keeps the protocol its adapter expects, so the form takes the protocol from the stage instead of the preset as a whole. Connections saved by the retired presets keep their provider identity: the five vLLM-Omni protocols resolve to the new preset instead of reading as "custom". The test that pinned vllm_omni to vllm-omni-video now pins the single service, and new cases cover the stage table, the per-kind options and the legacy protocols. --- src/canvas/ModelServiceForm.tsx | 14 ++-- src/canvas/providerPresets.ts | 113 +++++++++++++++++++------------- tests/providerPresets.test.ts | 72 +++++++++++++++++++- 3 files changed, 144 insertions(+), 55 deletions(-) diff --git a/src/canvas/ModelServiceForm.tsx b/src/canvas/ModelServiceForm.tsx index 91da74e1e..3bbf889bc 100644 --- a/src/canvas/ModelServiceForm.tsx +++ b/src/canvas/ModelServiceForm.tsx @@ -17,8 +17,10 @@ import { } from "../backend/rules.ts"; import { ModelCapabilityCard } from "./ModelCapabilityCard"; import { + LOCAL_OMNI_PRESET_ID, PROVIDER_PRESETS, matchingConnections, + presetProtocol, providerPresetFor, } from "./providerPresets"; import { CanvasIcon } from "./CanvasIcon"; @@ -71,13 +73,9 @@ export function ModelServiceForm({ const [presetId, setPresetId] = useState( existing ? providerPresetFor(existing) - : kind === "video" - ? "vllm-omni-video" - : kind === "image" - ? "vllm-omni-image" - : kind === "audio" - ? "vllm-omni-speech" - : "custom", + : kind === "video" || kind === "image" || kind === "audio" + ? LOCAL_OMNI_PRESET_ID + : "custom", ); const [modelOptions, setModelOptions] = useState< Record @@ -269,7 +267,7 @@ export function ModelServiceForm({ apiKey: "", videoAdapter: "auto", url: preset?.url ?? "", - protocol: preset?.protocol ?? PROTOCOLS[kind][0][0], + protocol: presetProtocol(preset, kind) ?? PROTOCOLS[kind][0][0], connectionType: preset?.connectionType ?? "self_hosted", authMode: preset?.authMode ?? "none", proxyMode: "direct", diff --git a/src/canvas/providerPresets.ts b/src/canvas/providerPresets.ts index 8760e32d5..0006a50c3 100644 --- a/src/canvas/providerPresets.ts +++ b/src/canvas/providerPresets.ts @@ -16,23 +16,11 @@ const EN_NAMES: Record = { "MiniMax 官方语音": "MiniMax Official Speech", "MOSS 开放平台": "MOSS Open Platform", "火山方舟 / Agent Plan": "Volcano Ark / Agent Plan", - "vLLM-Omni 图片接口": "vLLM-Omni image API", - "vLLM-Omni 语音合成接口": "vLLM-Omni speech synthesis API", - "vLLM-Omni 音乐生成接口": "vLLM-Omni music generation API", - "vLLM-Omni 扒谱接口": "vLLM-Omni transcription API", - "vLLM-Omni 视频接口": "vLLM-Omni video API", - "vLLM-Omni 分割接口": "vLLM-Omni segmentation API", - "vLLM-Omni 深度接口": "vLLM-Omni depth API", + "vLLM-Omni 本地服务": "vLLM-Omni local service", }; const EN_OPTION_LABELS: Record = { - 图片接口: "Image API", - 语音合成接口: "Speech synthesis API", - 音乐生成接口: "Music generation API", - 扒谱接口: "Transcription API", - 视频接口: "Video API", - 分割接口: "Segmentation API", - 深度接口: "Depth API", + 本地服务: "Local service", }; const EN_GROUPS: Record = { @@ -55,6 +43,13 @@ function groupLabel(value: string | undefined): string | undefined { return getActiveLocale() === "en-US" ? (EN_GROUPS[value] ?? value) : value; } +/** One stage of a multi-stage self-hosted service: the endpoints it serves. */ +export interface ProviderStage { + /** Endpoint paths appended to the connection URL, e.g. `/images/generations`. */ + paths: readonly string[]; + protocol: ModelConfigInput["protocol"]; +} + export interface ProviderPreset { id: string; name: string; @@ -68,6 +63,12 @@ export interface ProviderPreset { connectionType: ModelConfigInput["connectionType"]; authMode: ModelConfigInput["authMode"]; modelsByKind?: Partial>; + /** + * Per-kind endpoints of a service that serves several stages behind one + * connection. Absent for single-purpose presets, where `url` + `protocol` + * describe the whole connection. + */ + stages?: Partial>; } export const PROVIDER_PRESETS: ProviderPreset[] = [ @@ -257,40 +258,56 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [ connectionType: "api", authMode: "bearer", }, - ...( - [ - ["vllm-omni-image", "vLLM-Omni 图片接口", "openai", ["image"]], - ["vllm-omni-speech", "vLLM-Omni 语音合成接口", "openai", ["audio"]], - [ - "vllm-omni-music", - "vLLM-Omni 音乐生成接口", - "vllm_omni_music", - ["audio"], - ], - ["vllm-omni-score", "vLLM-Omni 扒谱接口", "vllm_omni_score", ["audio"]], - ["vllm-omni-video", "vLLM-Omni 视频接口", "vllm_omni", ["video"]], - [ - "vllm-omni-segmentation", - "vLLM-Omni 分割接口", - "vllm_omni_segmentation", - ["image", "video", "vision"], - ], - ["vllm-omni-depth", "vLLM-Omni 深度接口", "vllm_omni_depth", ["video"]], - ] as const - ).map(([id, name, protocol, kinds]) => ({ - id, - name, - group: "vLLM-Omni", + { + id: "vllm-omni-local", logoOrganization: "vllm-project", - optionLabel: name.replace("vLLM-Omni ", ""), - protocol, - kinds: [...kinds], - url: "", - connectionType: "self_hosted" as const, - authMode: "none" as const, - })), + name: "vLLM-Omni 本地服务", + optionLabel: "本地服务", + group: "vLLM-Omni", + kinds: ["agent", "image", "video", "audio", "vision"], + url: "http://127.0.0.1:8000/v1", + protocol: "vllm_omni", + connectionType: "self_hosted", + authMode: "none", + // One localhost service serves several stages; each stage keeps the + // protocol its adapter expects, so a single connection is enough. + stages: { + agent: { paths: ["/chat/completions"], protocol: "openai" }, + image: { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, + video: { paths: ["/videos"], protocol: "vllm_omni" }, + audio: { paths: ["/audio/speech", "/audio/transcriptions"], protocol: "openai" }, + vision: { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + }, + }, +]; + +export const LOCAL_OMNI_PRESET_ID = "vllm-omni-local"; + +/** + * Protocols a saved self-hosted connection may still carry from the retired + * per-stage vLLM-Omni presets. They now resolve to the one local service, so + * an existing configuration keeps its provider name instead of reading as + * "custom". + */ +const OMNI_STAGE_PROTOCOLS: readonly ModelConfigInput["protocol"][] = [ + "vllm_omni", + "vllm_omni_music", + "vllm_omni_score", + "vllm_omni_segmentation", + "vllm_omni_depth", ]; +/** The protocol a connection uses for one kind; falls back to the preset's own. */ +export function presetProtocol( + preset: ProviderPreset | undefined, + kind: ModelKind, +): ModelConfigInput["protocol"] | undefined { + return preset?.stages?.[kind]?.protocol ?? preset?.protocol; +} + export function providerPresetFor(model: ModelConfig): string { const explicit = PROVIDER_PRESETS.find( (preset) => @@ -300,6 +317,12 @@ export function providerPresetFor(model: ModelConfig): string { preset.kinds.includes(model.kind), ); if (explicit) return explicit.id; + if ( + model.connectionType === "self_hosted" && + model.protocol && + OMNI_STAGE_PROTOCOLS.includes(model.protocol) + ) + return LOCAL_OMNI_PRESET_ID; const deployed = PROVIDER_PRESETS.find( (preset) => preset.connectionType === "self_hosted" && diff --git a/tests/providerPresets.test.ts b/tests/providerPresets.test.ts index 39d5bcf8d..34ac98b06 100644 --- a/tests/providerPresets.test.ts +++ b/tests/providerPresets.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { PROVIDER_PRESETS, matchingConnections, providerOptions, providerPresetFor } from "../src/canvas/providerPresets.ts"; +import { LOCAL_OMNI_PRESET_ID, PROVIDER_PRESETS, matchingConnections, presetProtocol, providerOptions, providerPresetFor } from "../src/canvas/providerPresets.ts"; import type { ModelConfig } from "../src/backend/rules.ts"; import { modelDescription } from "../src/canvas/modelDescriptions.ts"; import { getActiveLocale, setActiveLocale } from "../src/i18n/messages.ts"; @@ -63,7 +63,7 @@ test("provider presets separate official protocol from self-hosted model names", assert.deepEqual(official.modelsByKind?.video, ["MiniMax-H3", "MiniMax-H3-Highspeed", "MiniMax-H3-Lite", "MiniMax-H3-Max"]); const model: ModelConfig = { ...official, id: "one", kind: "video", modelId: "MiniMax-H3", inputRules: { profile: "", allowedKinds: [], maxImages: 0, maxVideos: 0, maxAudios: 0, videoModes: [] } }; assert.equal(providerPresetFor(model), "minimax-video"); - assert.equal(providerPresetFor({ ...model, connectionType: "self_hosted", protocol: "vllm_omni" }), "vllm-omni-video"); + assert.equal(providerPresetFor({ ...model, connectionType: "self_hosted", protocol: "vllm_omni" }), "vllm-omni-local"); assert.deepEqual(matchingConnections([{ ...model, providerId: "shared" }, { ...model, id: "two", providerId: "shared" }, { ...model, id: "three", providerId: "other" }], "video", { ...model, protocol: "minimax_video_v2", authMode: "bearer", apiKey: "" }).map((item) => item.id), ["one", "three"]); }); @@ -397,3 +397,71 @@ test("a saved Zhipu GLM-TTS connection reopens with its provider identity", () = assert.equal(providerPresetFor(model), "zhipu"); assert.equal(providerPresetFor({ ...model, url: "https://other.test/v1" }), "custom"); }); + +test("vLLM-Omni is one local service with an endpoint per stage", () => { + const preset = PROVIDER_PRESETS.find((item) => item.id === LOCAL_OMNI_PRESET_ID)!; + assert.equal(preset.url, "http://127.0.0.1:8000/v1"); + assert.equal(preset.connectionType, "self_hosted"); + assert.equal(preset.authMode, "none"); + assert.deepEqual(preset.kinds, ["agent", "image", "video", "audio", "vision"]); + assert.deepEqual(preset.stages, { + agent: { paths: ["/chat/completions"], protocol: "openai" }, + image: { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, + video: { paths: ["/videos"], protocol: "vllm_omni" }, + audio: { paths: ["/audio/speech", "/audio/transcriptions"], protocol: "openai" }, + vision: { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + }); + for (const kind of ["agent", "image", "video", "audio", "vision"] as const) { + assert.equal(presetProtocol(preset, kind), preset.stages![kind]!.protocol); + } + // The retired per-stage presets leave exactly one entry per kind behind. + for (const kind of ["agent", "image", "video", "audio", "vision"] as const) { + const omni = providerOptions(kind).filter((item) => item.id.startsWith("vllm-omni")); + assert.deepEqual(omni.map((item) => item.id), [LOCAL_OMNI_PRESET_ID]); + assert.equal(omni[0]?.group, getActiveLocale() === "en-US" ? "vLLM-Omni compatible" : "vLLM-Omni 兼容"); + } +}); + +test("saved self-hosted vLLM-Omni connections resolve to the local service", () => { + const preset = PROVIDER_PRESETS.find((item) => item.id === LOCAL_OMNI_PRESET_ID)!; + const saved = (protocol: ModelConfig["protocol"], kind: ModelConfig["kind"]): ModelConfig => ({ + ...preset, id: `saved-${protocol}`, kind, protocol, modelId: "m", + inputRules: { profile: "", allowedKinds: [], maxImages: 0, maxVideos: 0, maxAudios: 0, videoModes: [] }, + }); + // Every protocol the retired per-stage presets wrote must keep its name. + for (const [protocol, kind] of [ + ["vllm_omni", "video"], + ["vllm_omni_music", "audio"], + ["vllm_omni_score", "audio"], + ["vllm_omni_depth", "video"], + ["vllm_omni_segmentation", "vision"], + ] as const) { + assert.equal(providerPresetFor(saved(protocol, kind)), LOCAL_OMNI_PRESET_ID); + } + // A hosted connection with another URL keeps reading as custom; the same + // localhost URL still resolves to the local service. + assert.equal(providerPresetFor({ ...saved("vllm_omni", "video"), connectionType: "api", url: "https://elsewhere.test/v1" }), "custom"); + assert.equal(providerPresetFor({ ...saved("vllm_omni", "video"), connectionType: "api" }), LOCAL_OMNI_PRESET_ID); + assert.equal(providerPresetFor(saved("openai", "audio")), "custom"); +}); + +test("the local vLLM-Omni service reads in both languages", () => { + const preset = PROVIDER_PRESETS.find((item) => item.id === LOCAL_OMNI_PRESET_ID)!; + const previous = getActiveLocale(); + try { + for (const [locale, name, label] of [ + ["zh-CN", "vLLM-Omni 本地服务", "本地服务"], + ["en-US", "vLLM-Omni local service", "Local service"], + ] as const) { + setActiveLocale(locale); + const option = providerOptions("video").find((item) => item.id === preset.id); + assert.equal(option?.name, name); + assert.equal(option?.optionLabel, label); + } + } finally { + setActiveLocale(previous); + } +}); From dcea95de10a6a4041abda30fac37954444a8b87f Mon Sep 17 00:00:00 2001 From: Xingkai98 Date: Thu, 19 Nov 2026 15:48:42 +0800 Subject: [PATCH 2/4] fix(canvas): keep every local Omni stage reachable and identified - Offer each per-kind stage through a stage selector instead of pinning the first protocol: image (generation, segmentation), video (generation, segmentation, depth), and audio (TTS, music, score). - Keep the local service's URL, auth mode and protocol as the defaults when the form opens on a self-hosted preset. - Resolve saved loopback `openai` stage connections to the local service; non-loopback generic OpenAI-compatible services still read as custom. Co-Authored-By: Claude Code --- src/canvas/ModelServiceForm.tsx | 78 ++++++++++++++++++--- src/canvas/model-settings.css | 1 + src/canvas/providerPresets.ts | 111 +++++++++++++++++++++--------- src/i18n/messages/en-US/models.ts | 2 + src/i18n/messages/zh-CN/models.ts | 2 + tests/providerPresets.test.ts | 52 +++++++++++--- 6 files changed, 193 insertions(+), 53 deletions(-) diff --git a/src/canvas/ModelServiceForm.tsx b/src/canvas/ModelServiceForm.tsx index 3bbf889bc..cd339fc3c 100644 --- a/src/canvas/ModelServiceForm.tsx +++ b/src/canvas/ModelServiceForm.tsx @@ -21,6 +21,7 @@ import { PROVIDER_PRESETS, matchingConnections, presetProtocol, + presetStages, providerPresetFor, } from "./providerPresets"; import { CanvasIcon } from "./CanvasIcon"; @@ -70,29 +71,40 @@ export function ModelServiceForm({ const t = useT(); const connectionFieldId = useId(); const [connection, setConnection] = useState(existing); - const [presetId, setPresetId] = useState( - existing - ? providerPresetFor(existing) - : kind === "video" || kind === "image" || kind === "audio" - ? LOCAL_OMNI_PRESET_ID - : "custom", + const initialPresetId = existing + ? providerPresetFor(existing) + : kind === "video" || kind === "image" || kind === "audio" + ? LOCAL_OMNI_PRESET_ID + : "custom"; + const initialPreset = PROVIDER_PRESETS.find( + (item) => item.id === initialPresetId, ); + // The custom preset shows a sample hosted endpoint; leave it empty so the + // user enters their own service. Self-hosted presets carry real defaults. + const initialDefaults = + initialPreset?.connectionType === "self_hosted" ? initialPreset : undefined; + const [presetId, setPresetId] = useState(initialPresetId); const [modelOptions, setModelOptions] = useState< Record >({}); const [modelErrors, setModelErrors] = useState>({}); const [value, setValue] = useState({ kind, - url: existing?.url ?? "", + url: existing?.url ?? initialDefaults?.url ?? "", modelId: existing?.modelId ?? "", apiKey: "", - connectionType: existing?.connectionType ?? "self_hosted", + connectionType: + existing?.connectionType ?? + initialDefaults?.connectionType ?? + "self_hosted", capabilityAutoCheck: existing?.capabilityAutoCheck, protocol: existing && isSegmentationModel(existing) ? "vllm_omni_segmentation" - : (existing?.protocol ?? PROTOCOLS[kind][0][0]), - authMode: existing?.authMode ?? "none", + : (existing?.protocol ?? + presetProtocol(initialDefaults, kind) ?? + PROTOCOLS[kind][0][0]), + authMode: existing?.authMode ?? initialDefaults?.authMode ?? "none", proxyMode: existing ? (existing.proxyMode ?? "system") : "direct", videoAdapter: existing?.videoAdapter ?? "auto", inputModalities: @@ -125,6 +137,17 @@ export function ModelServiceForm({ const segmentation = value.protocol === "vllm_omni_segmentation"; const depth = value.protocol === "vllm_omni_depth"; const score = value.protocol === "vllm_omni_score"; + const selectedPreset = PROVIDER_PRESETS.find((item) => item.id === presetId); + const stages = presetStages(selectedPreset, kind); + const activeStage = stages.find( + (stage) => stage.protocol === value.protocol, + ); + const protocolLabel = (protocol: ModelConfigInput["protocol"]) => { + const option = PROTOCOLS[kind].find( + ([candidate]) => candidate === protocol, + ); + return option ? t(option[1]) : protocol; + }; const hasSavedKey = Boolean( connection && connection.authMode === "bearer" && @@ -356,6 +379,41 @@ export function ModelServiceForm({ disabled={locked} onChange={chooseProvider} /> + {stages.length > 1 && ( +
+
+ + {activeStage && ( +

+ {t("models.service.stageEndpoints", { + paths: activeStage.paths.join(", "), + })} +

+ )} +
+
+ )} {!connection && connections.length > 0 && (
{t("models.service.existingConnections")} diff --git a/src/canvas/model-settings.css b/src/canvas/model-settings.css index 0be4112d2..d1f30ecd8 100644 --- a/src/canvas/model-settings.css +++ b/src/canvas/model-settings.css @@ -660,6 +660,7 @@ .cw-model-picker.has-capability-cards .cw-model-options { max-height: none; } .cw-model-editor-scroll > .cw-model-connection-details { margin: 0 0 16px; } +.cw-model-editor-scroll > .cw-provider-stage { margin: 0 0 16px; } .cw-model-editor-scroll > .cw-provider-key { margin: 0 0 18px; } .cw-model-availability { padding: 12px 0; font-size: var(--settings-label-size, 13px); } diff --git a/src/canvas/providerPresets.ts b/src/canvas/providerPresets.ts index 0006a50c3..33f0f7903 100644 --- a/src/canvas/providerPresets.ts +++ b/src/canvas/providerPresets.ts @@ -64,11 +64,12 @@ export interface ProviderPreset { authMode: ModelConfigInput["authMode"]; modelsByKind?: Partial>; /** - * Per-kind endpoints of a service that serves several stages behind one - * connection. Absent for single-purpose presets, where `url` + `protocol` - * describe the whole connection. + * Per-kind stages of a service that serves several endpoints behind one + * connection. The first stage is the kind's default. Absent for + * single-purpose presets, where `url` + `protocol` describe the whole + * connection. */ - stages?: Partial>; + stages?: Partial>; } export const PROVIDER_PRESETS: ProviderPreset[] = [ @@ -270,42 +271,82 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [ connectionType: "self_hosted", authMode: "none", // One localhost service serves several stages; each stage keeps the - // protocol its adapter expects, so a single connection is enough. + // protocol its adapter expects, so a single connection is enough. The + // first stage of each kind is the default. + // + // ASR is deliberately absent: vllm-omni does not serve + // /audio/transcriptions yet (S1 in #10007) and this application has no ASR + // adapter. SheetSage2 score shares the path with its own protocol. stages: { - agent: { paths: ["/chat/completions"], protocol: "openai" }, - image: { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, - video: { paths: ["/videos"], protocol: "vllm_omni" }, - audio: { paths: ["/audio/speech", "/audio/transcriptions"], protocol: "openai" }, - vision: { - paths: ["/images/segmentations", "/videos/segmentations"], - protocol: "vllm_omni_segmentation", - }, + agent: [{ paths: ["/chat/completions"], protocol: "openai" }], + image: [ + { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + ], + video: [ + { paths: ["/videos"], protocol: "vllm_omni" }, + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + { paths: ["/videos/depth"], protocol: "vllm_omni_depth" }, + ], + audio: [ + { paths: ["/audio/speech"], protocol: "openai" }, + { paths: ["/audio/speech"], protocol: "vllm_omni_music" }, + { paths: ["/audio/transcriptions"], protocol: "vllm_omni_score" }, + ], + vision: [ + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + ], }, }, ]; export const LOCAL_OMNI_PRESET_ID = "vllm-omni-local"; +/** The stages a preset serves for one kind; empty for single-purpose presets. */ +export function presetStages( + preset: ProviderPreset | undefined, + kind: ModelKind, +): readonly ProviderStage[] { + return preset?.stages?.[kind] ?? []; +} + /** - * Protocols a saved self-hosted connection may still carry from the retired - * per-stage vLLM-Omni presets. They now resolve to the one local service, so - * an existing configuration keeps its provider name instead of reading as - * "custom". + * The protocol a connection uses for one kind. A protocol that names one of + * the preset's stages is kept, so reopening a saved specialized connection + * does not silently switch it back to the kind's default stage. */ -const OMNI_STAGE_PROTOCOLS: readonly ModelConfigInput["protocol"][] = [ - "vllm_omni", - "vllm_omni_music", - "vllm_omni_score", - "vllm_omni_segmentation", - "vllm_omni_depth", -]; - -/** The protocol a connection uses for one kind; falls back to the preset's own. */ export function presetProtocol( preset: ProviderPreset | undefined, kind: ModelKind, + protocol?: ModelConfigInput["protocol"] | null, ): ModelConfigInput["protocol"] | undefined { - return preset?.stages?.[kind]?.protocol ?? preset?.protocol; + const stages = presetStages(preset, kind); + if (protocol && stages.some((stage) => stage.protocol === protocol)) + return protocol; + return stages[0]?.protocol ?? preset?.protocol; +} + +/** + * `openai` is shared by generic self-hosted services, so it identifies this + * preset only at the documented loopback default. The specialized vLLM-Omni + * protocols are unique and need no URL rule. + */ +function isLoopbackUrl(value: string): boolean { + try { + const host = new URL(value).hostname.replace(/^\[|\]$/g, ""); + return host === "localhost" || host === "127.0.0.1" || host === "::1"; + } catch { + return false; + } } export function providerPresetFor(model: ModelConfig): string { @@ -317,12 +358,16 @@ export function providerPresetFor(model: ModelConfig): string { preset.kinds.includes(model.kind), ); if (explicit) return explicit.id; - if ( - model.connectionType === "self_hosted" && - model.protocol && - OMNI_STAGE_PROTOCOLS.includes(model.protocol) - ) - return LOCAL_OMNI_PRESET_ID; + const staged = PROVIDER_PRESETS.find( + (preset) => + model.connectionType === "self_hosted" && + preset.kinds.includes(model.kind) && + presetStages(preset, model.kind).some( + (stage) => stage.protocol === model.protocol, + ) && + (model.protocol !== "openai" || isLoopbackUrl(model.url)), + ); + if (staged) return staged.id; const deployed = PROVIDER_PRESETS.find( (preset) => preset.connectionType === "self_hosted" && diff --git a/src/i18n/messages/en-US/models.ts b/src/i18n/messages/en-US/models.ts index 1cbeb068e..dde69006f 100644 --- a/src/i18n/messages/en-US/models.ts +++ b/src/i18n/messages/en-US/models.ts @@ -129,6 +129,8 @@ export const models = { "models.service.saving": "Saving…", "models.service.cancel": "Cancel", "models.service.advancedConnection": "Advanced connection settings", + "models.service.stage": "Stage", + "models.service.stageEndpoints": "Endpoints: {paths}", "models.service.existingConnections": "Connections with the same address", "models.service.reuseConnection": "Reuse saved connection · {model}", diff --git a/src/i18n/messages/zh-CN/models.ts b/src/i18n/messages/zh-CN/models.ts index 75a638788..0aa9a04cf 100644 --- a/src/i18n/messages/zh-CN/models.ts +++ b/src/i18n/messages/zh-CN/models.ts @@ -107,6 +107,8 @@ export const models = { "models.service.saving": "保存中…", "models.service.cancel": "取消", "models.service.advancedConnection": "高级连接设置", + "models.service.stage": "接口阶段", + "models.service.stageEndpoints": "接口路径:{paths}", "models.service.existingConnections": "已有相同地址的连接", "models.service.reuseConnection": "复用已保存连接 · {model}", "models.service.reuseHint": "不复用则保存为独立连接。", diff --git a/tests/providerPresets.test.ts b/tests/providerPresets.test.ts index 34ac98b06..aa310a090 100644 --- a/tests/providerPresets.test.ts +++ b/tests/providerPresets.test.ts @@ -405,18 +405,41 @@ test("vLLM-Omni is one local service with an endpoint per stage", () => { assert.equal(preset.authMode, "none"); assert.deepEqual(preset.kinds, ["agent", "image", "video", "audio", "vision"]); assert.deepEqual(preset.stages, { - agent: { paths: ["/chat/completions"], protocol: "openai" }, - image: { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, - video: { paths: ["/videos"], protocol: "vllm_omni" }, - audio: { paths: ["/audio/speech", "/audio/transcriptions"], protocol: "openai" }, - vision: { - paths: ["/images/segmentations", "/videos/segmentations"], - protocol: "vllm_omni_segmentation", - }, + agent: [{ paths: ["/chat/completions"], protocol: "openai" }], + image: [ + { paths: ["/images/generations", "/images/edits"], protocol: "openai" }, + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + ], + video: [ + { paths: ["/videos"], protocol: "vllm_omni" }, + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + { paths: ["/videos/depth"], protocol: "vllm_omni_depth" }, + ], + audio: [ + { paths: ["/audio/speech"], protocol: "openai" }, + { paths: ["/audio/speech"], protocol: "vllm_omni_music" }, + { paths: ["/audio/transcriptions"], protocol: "vllm_omni_score" }, + ], + vision: [ + { + paths: ["/images/segmentations", "/videos/segmentations"], + protocol: "vllm_omni_segmentation", + }, + ], }); for (const kind of ["agent", "image", "video", "audio", "vision"] as const) { - assert.equal(presetProtocol(preset, kind), preset.stages![kind]!.protocol); + assert.equal(presetProtocol(preset, kind), preset.stages![kind]![0]!.protocol); } + // A saved specialized stage keeps its protocol; only an unknown one falls + // back to the kind's first stage. + assert.equal(presetProtocol(preset, "audio", "vllm_omni_music"), "vllm_omni_music"); + assert.equal(presetProtocol(preset, "audio", "vllm_omni_depth"), "openai"); // The retired per-stage presets leave exactly one entry per kind behind. for (const kind of ["agent", "image", "video", "audio", "vision"] as const) { const omni = providerOptions(kind).filter((item) => item.id.startsWith("vllm-omni")); @@ -437,15 +460,24 @@ test("saved self-hosted vLLM-Omni connections resolve to the local service", () ["vllm_omni_music", "audio"], ["vllm_omni_score", "audio"], ["vllm_omni_depth", "video"], + ["vllm_omni_segmentation", "image"], + ["vllm_omni_segmentation", "video"], ["vllm_omni_segmentation", "vision"], ] as const) { assert.equal(providerPresetFor(saved(protocol, kind)), LOCAL_OMNI_PRESET_ID); } + // `openai` is shared with generic local services, so it only identifies the + // preset at a loopback address. + for (const kind of ["agent", "image", "audio"] as const) { + assert.equal(providerPresetFor(saved("openai", kind)), LOCAL_OMNI_PRESET_ID); + } + for (const url of ["http://192.168.1.5:8000/v1", "https://local.example/v1"]) { + assert.equal(providerPresetFor({ ...saved("openai", "audio"), url }), "custom"); + } // A hosted connection with another URL keeps reading as custom; the same // localhost URL still resolves to the local service. assert.equal(providerPresetFor({ ...saved("vllm_omni", "video"), connectionType: "api", url: "https://elsewhere.test/v1" }), "custom"); assert.equal(providerPresetFor({ ...saved("vllm_omni", "video"), connectionType: "api" }), LOCAL_OMNI_PRESET_ID); - assert.equal(providerPresetFor(saved("openai", "audio")), "custom"); }); test("the local vLLM-Omni service reads in both languages", () => { From ebd8d742593bfca2ad8d0358ce40ad32692d64a9 Mon Sep 17 00:00:00 2001 From: Xingkai98 Date: Thu, 19 Nov 2026 16:08:33 +0800 Subject: [PATCH 3/4] test(browser): follow the single local Omni preset - Provider settings checks the per-kind stage selector and endpoint note instead of the retired per-stage preset names. - Kling and MOSS flows expect the new default provider name. Co-Authored-By: Claude Code --- tests/browser/kling_video.mjs | 4 +-- tests/browser/moss_provider.mjs | 4 +-- tests/browser/provider_settings.mjs | 53 ++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/tests/browser/kling_video.mjs b/tests/browser/kling_video.mjs index 7b9518c2f..b9e3adc95 100644 --- a/tests/browser/kling_video.mjs +++ b/tests/browser/kling_video.mjs @@ -49,7 +49,7 @@ const copy = { video: "Video", add: "Add service", provider: "Provider", - defaultProvider: "vLLM-Omni video API", + defaultProvider: "vLLM-Omni local service", kling: "Kling official video", url: "Service URL (Base URL)", save: "Save service", @@ -69,7 +69,7 @@ const copy = { video: "视频", add: "添加服务", provider: "提供商", - defaultProvider: "vLLM-Omni 视频接口", + defaultProvider: "vLLM-Omni 本地服务", kling: "可灵官方视频", url: "服务地址(Base URL)", save: "保存服务", diff --git a/tests/browser/moss_provider.mjs b/tests/browser/moss_provider.mjs index b3cab056e..e14a143e6 100644 --- a/tests/browser/moss_provider.mjs +++ b/tests/browser/moss_provider.mjs @@ -51,14 +51,14 @@ const copy = { settings: "设置", models: "模型接入", imageOverview: "图片模型", image: "图片", audio: "音频", add: "添加服务", provider: "提供商", moss: "MOSS 开放平台", url: "服务地址(Base URL)", reload: "载入支持的模型", save: "保存服务", cancel: "取消", manage: "管理", close: "关闭设置", - general: "通用", language: "语言", defaultImage: "vLLM-Omni 图片接口", defaultAudio: "vLLM-Omni 语音合成接口", + general: "通用", language: "语言", defaultImage: "vLLM-Omni 本地服务", defaultAudio: "vLLM-Omni 本地服务", custom: "OpenAI 兼容", fetch: "获取模型", discoveryError: "服务返回 HTTP 401,请检查 API Key。", }, "en-US": { settings: "Settings", models: "Model connections", imageOverview: "Image model", image: "Image", audio: "Audio", add: "Add service", provider: "Provider", moss: "MOSS Open Platform", url: "Service URL (Base URL)", reload: "Load supported models", save: "Save service", cancel: "Cancel", manage: "Manage", close: "Close settings", - general: "General", language: "Language", defaultImage: "vLLM-Omni image API", defaultAudio: "vLLM-Omni speech synthesis API", + general: "General", language: "Language", defaultImage: "vLLM-Omni local service", defaultAudio: "vLLM-Omni local service", custom: "OpenAI compatible", fetch: "Fetch models", discoveryError: "Service returned HTTP 401. Check the API Key.", }, }; diff --git a/tests/browser/provider_settings.mjs b/tests/browser/provider_settings.mjs index 5cd8f904c..d164f07c9 100644 --- a/tests/browser/provider_settings.mjs +++ b/tests/browser/provider_settings.mjs @@ -36,19 +36,29 @@ try { await page.getByRole("button", { name: "Settings", exact: true }).click(); await page.getByRole("button", { name: "Model connections", exact: true }).click(); await page.locator(".cw-model-setup-row").filter({ hasText: "Image model" }).getByRole("button").click(); - for (const [category, interfaces] of [ - ["Image", ["vLLM-Omni image API", "vLLM-Omni segmentation API"]], - ["Audio", ["vLLM-Omni speech synthesis API", "vLLM-Omni music generation API", "vLLM-Omni transcription API"]], - ["Chat", ["OpenAI compatible"]], + for (const [category, stageCount, defaultStage, endpoints] of [ + ["Image", 2, "OpenAI-compatible API (including gpt-image and vLLM-Omni Z-Image-Turbo)", "Endpoints: /images/generations, /images/edits"], + ["Audio", 3, "OpenAI-compatible speech synthesis (including vLLM-Omni TTS)", "Endpoints: /audio/speech"], + ["Chat", 0, null, null], ]) { await page.getByRole("button", { name: category, exact: true }).click(); await page.getByRole("button", { name: "Add service", exact: true }).click(); - for (const name of interfaces) { - await page.getByRole("combobox", { name: "Provider", exact: true }).click(); - assert.equal(await page.getByRole("listbox", { name: "Provider", exact: true }).getByRole("option").first().getAttribute("aria-label"), "OpenAI compatible"); - assert.equal(await page.getByRole("option", { name: "Custom service", exact: true }).count(), 0); - await page.getByRole("option", { name, exact: true }).click(); - assert.equal(await page.getByText("API protocol", { exact: true }).count(), 0); + await page.getByRole("combobox", { name: "Provider", exact: true }).click(); + assert.equal(await page.getByRole("listbox", { name: "Provider", exact: true }).getByRole("option").first().getAttribute("aria-label"), "OpenAI compatible"); + assert.equal(await page.getByRole("option", { name: "Custom service", exact: true }).count(), 0); + await page.getByRole("option", { name: "vLLM-Omni local service", exact: true }).click(); + assert.equal(await page.getByText("API protocol", { exact: true }).count(), 0); + assert.equal( + await page.getByLabel("Service URL (Base URL)", { exact: true }).inputValue(), + "http://127.0.0.1:8000/v1", + ); + const stage = page.getByRole("combobox", { name: "Stage", exact: true }); + if (stageCount) { + assert.equal(await stage.locator("option").count(), stageCount); + assert.equal(await stage.locator("option:checked").innerText(), defaultStage); + assert.equal(await page.getByText(endpoints, { exact: true }).count(), 1); + } else { + assert.equal(await stage.count(), 0); } await page.screenshot({ path: `/tmp/provider-${category}.png` }); await page.getByRole("button", { name: "Cancel", exact: true }).click(); @@ -57,13 +67,24 @@ try { await page.getByRole("button", { name: "Add service", exact: true }).click(); await page.getByRole("combobox", { name: "Provider", exact: true }).click(); assert.equal(await page.getByRole("option", { name: "Custom service", exact: true }).count(), 0); - assert.equal(await page.getByRole("group", { name: "vLLM-Omni compatible", exact: true }).getByRole("option").count(), 3); - for (const name of ["vLLM-Omni video API", "vLLM-Omni segmentation API", "vLLM-Omni depth API"]) { - await page.getByRole("option", { name, exact: true }).click(); - assert.equal(await page.getByText("API protocol", { exact: true }).count(), 0); - assert.equal(await page.getByRole("combobox", { name: "Provider", exact: true }).innerText(), name); - await page.getByRole("combobox", { name: "Provider", exact: true }).click(); + const omniGroup = page.getByRole("group", { name: "vLLM-Omni compatible", exact: true }); + assert.equal(await omniGroup.getByRole("option").count(), 1); + assert.equal(await omniGroup.getByRole("option").first().getAttribute("aria-label"), "vLLM-Omni local service"); + await page.getByRole("option", { name: "vLLM-Omni local service", exact: true }).click(); + assert.equal(await page.getByText("API protocol", { exact: true }).count(), 0); + assert.equal(await page.getByRole("combobox", { name: "Provider", exact: true }).innerText(), "vLLM-Omni local service"); + const videoStage = page.getByRole("combobox", { name: "Stage", exact: true }); + assert.equal(await videoStage.locator("option").count(), 3); + for (const [label, endpoints] of [ + ["Async /videos API (including vLLM-Omni)", "Endpoints: /videos"], + ["vLLM-Omni segmentation API (SAM 3)", "Endpoints: /images/segmentations, /videos/segmentations"], + ["vLLM-Omni depth API (Video Depth Anything)", "Endpoints: /videos/depth"], + ]) { + await videoStage.selectOption({ label }); + assert.equal(await page.getByText(endpoints, { exact: true }).count(), 1); } + await videoStage.selectOption({ label: "Async /videos API (including vLLM-Omni)" }); + await page.getByRole("combobox", { name: "Provider", exact: true }).click(); await page.getByRole("textbox", { name: "Search Provider" }).fill("MiniMax"); assert.equal(await page.getByRole("listbox", { name: "Provider", exact: true }).getByRole("option").count(), 1); await page.keyboard.press("Escape"); From 0c02927f97a637a7c6739a65c852ce0d66a58644 Mon Sep 17 00:00:00 2001 From: Xingkai98 Date: Thu, 19 Nov 2026 16:26:45 +0800 Subject: [PATCH 4/4] test(browser): isolate provider settings and harden canvas wait Provider settings now removes the model configurations it creates, so the shared fixture catalogue is left as it found it. The capability workflow waits up to 30 seconds for the externally created canvas node before clicking it; the suite can run well past the default 15-second timeout. Co-Authored-By: Claude Code --- tests/browser/capability_discovery.mjs | 6 +++++- tests/browser/provider_settings.mjs | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/browser/capability_discovery.mjs b/tests/browser/capability_discovery.mjs index 554f6f057..9a0ec968a 100644 --- a/tests/browser/capability_discovery.mjs +++ b/tests/browser/capability_discovery.mjs @@ -778,7 +778,11 @@ try { .getByText("Fixture catalogue unavailable", { exact: true }).waitFor(); await page.unroute("**/api/model-configs"); await page.getByRole("button", { name: "Close settings", exact: true }).click(); - await page.locator(`.react-flow__node[data-id="${itemId}"]`).click(); + const canvasNode = page.locator( + `.react-flow__node[data-id="${itemId}"]`, + ); + await canvasNode.waitFor({ timeout: 30000 }); + await canvasNode.click(); assert.equal(await page.locator(".cw-generation-composer button.cw-run-button").isEnabled(), true); assert.match(await page.locator(".cw-generation-composer").innerText(), /Preserve this prompt/); await page.getByRole("button", { name: "Settings", exact: true }).click(); diff --git a/tests/browser/provider_settings.mjs b/tests/browser/provider_settings.mjs index d164f07c9..60fa2b787 100644 --- a/tests/browser/provider_settings.mjs +++ b/tests/browser/provider_settings.mjs @@ -23,6 +23,9 @@ await page.addInitScript(() => { }); page.setDefaultTimeout(15000); const calls = []; +const initialModelIds = new Set( + (await call("/api/model-configs")).map((model) => model.id), +); page.on("request", (request) => calls.push(request.url())); try { const projectId = crypto.randomUUID(); @@ -234,4 +237,12 @@ try { throw error; } finally { await browser.close(); + // Leave the shared fixture catalogue as this workflow found it so later + // browser workflows do not inherit its saved services. + for (const model of await call("/api/model-configs").catch(() => [])) { + if (!initialModelIds.has(model.id)) + await call(`/api/model-configs/${model.id}`, undefined, "DELETE").catch( + () => {}, + ); + } }