Merge pull request '修复生效模型的参数映射与能力配置不一致' (#93) from codex/model-parameter-audit-20261116 into main

This commit is contained in:
WuYongJie 2026-11-16 14:43:59 +08:00
commit 4d739927f7
25 changed files with 394 additions and 81 deletions

View File

@ -623,7 +623,7 @@ async function resolveReplacementProductIdentityProfile(params: {
system:
"你是高精度商品结构分析器。多张图片属于同一商品;请跨视角还原唯一结构身份,并明确每个视角最清楚的构件。",
temperature: params.planningRuntime.kind === "local_moonshot" ? 1 : 0.1,
maxTokens: 1800,
maxOutputTokens: 1800,
abortSignal: AbortSignal.timeout(
params.planningRuntime.kind === "local_moonshot" ? 90_000 : 60_000,
),
@ -2376,7 +2376,7 @@ export async function analyzeReplacementReferenceImage(params: {
},
],
temperature: 0,
maxTokens: 160,
maxOutputTokens: 160,
abortSignal: AbortSignal.timeout(45_000),
} as any);
@ -2679,7 +2679,7 @@ export async function analyzeReplacementExecutionPlan(params: {
system:
"你是高精度商品详情图场景规划器。你只分析当前参考图本身,负责理解这一屏的场景、机位、主体位置和人物需求,不要臆测或依赖其他输入图片。",
temperature: params.planningRuntime.kind === "local_moonshot" ? 1 : 0.1,
maxTokens: 1600,
maxOutputTokens: 1600,
abortSignal: AbortSignal.timeout(replacementScenePlanningTimeoutMs),
} as any);

View File

@ -450,7 +450,7 @@ async function analyzeFunctionalShowcaseImage(params: {
},
],
temperature: 0,
maxTokens: 120,
maxOutputTokens: 120,
abortSignal: AbortSignal.timeout(25_000),
} as any);

View File

@ -1804,7 +1804,7 @@ async function runDualDirectorPlanPreflight(params: {
? "You are both an art director and a marketing director for high-conversion e-commerce detail pages. Output JSON only."
: "你同时扮演高转化电商详情页的平面设计总监与营销总监。仅输出JSON。",
temperature: params.isLocalMoonshot ? 1 : 0.1,
maxTokens: 2000,
maxOutputTokens: 2000,
...(params.kimiOptions || {}),
}, params.timeoutMs || DETAIL_PLAN_PREFLIGHT_TIMEOUT_MS);
@ -2040,7 +2040,7 @@ export async function POST(request: Request) {
kimiDetailProfile: plannerKimiOptions.headers
? {
thinking: plannerKimiOptions.headers["x-detail-agent-kimi-thinking"],
maxTokens: plannerKimiOptions.maxTokens,
maxOutputTokens: plannerKimiOptions.maxOutputTokens,
}
: null,
});
@ -2177,7 +2177,7 @@ export async function POST(request: Request) {
`{"summary":"简述","globalStyle":{"designLanguage":"一句话风格方向","typography":{"fontFamily":"字体家族","title":"主标题规范","subtitle":"副标题规范","body":"正文规范"},"layout":{"grid":"栅格","safeArea":"安全区","rhythm":"留白节奏"},"palette":"配色规范"},"screens":[{"index":1,"screenType":"B","objective":"本屏目标","title":"首屏示例:甩甩杆,自拍不手抖(6-20字)","subtitle":"一句副标题","copy":"正文文案","layoutNote":"排版说明","useModel":false,"modelReason":"是否需要人物及原因","bundleShowcase":false,"bundleReason":"是否为搭配展示页及原因","fabe":{"b":"利益","f":"特征","a":"优势","e":"证据"},"visualPrompt":"用于生图的完整提示词,必须包含790x1300与统一字体排版"}],"dslV2Screens":[{"version":"detail-ui-dsl/v2","screenIndex":1,"layoutVariant":"hero-left-panel","region":{"x":0.06,"y":0.05,"width":0.88,"height":0.46},"nodes":[{"kind":"panel","id":"hero-panel","variant":"glass","tone":"light","direction":"column","gap":18,"children":[{"kind":"badge","id":"screen-badge","icon":"sparkle","text":"核心升级","tone":"primary"},{"kind":"heading","id":"hero-title","text":"护腰椅,久坐不腰酸","level":1,"emphasis":"hero"},{"kind":"body","id":"hero-subtitle","text":"在家里加班,也能护腰/舒适","emphasis":"strong"}]}]}]}`,
temperature: 0.25,
...(localDetailAgentResolved ? { temperature: 1 } : {}),
maxTokens: 1800,
maxOutputTokens: 1800,
...plannerKimiOptions,
});

View File

@ -323,7 +323,7 @@ export async function POST(request: Request) {
kimiDetailProfile: reviewKimiOptions.headers
? {
thinking: reviewKimiOptions.headers["x-detail-agent-kimi-thinking"],
maxTokens: reviewKimiOptions.maxTokens,
maxOutputTokens: reviewKimiOptions.maxOutputTokens,
}
: null,
});
@ -438,7 +438,7 @@ export async function POST(request: Request) {
? "You are both an Art Director and a Marketing Director for high-conversion e-commerce detail pages. Evaluate with strict professional standards and output JSON only."
: "你同时是高转化电商详情页的平面设计总监与营销总监。按严格专业标准评估,仅输出JSON。",
temperature: localDetailAgentResolved ? 1 : 0.1,
maxTokens: 800,
maxOutputTokens: 800,
...reviewKimiOptions,
} as any);
text = String(result?.text || "");

View File

@ -114,7 +114,7 @@ export async function POST(request: NextRequest) {
},
],
temperature: 0.2,
maxTokens: 1200,
maxOutputTokens: 1200,
} as any);
return NextResponse.json({

View File

@ -15626,7 +15626,8 @@ function VideoTargetModuleComposer({
const ratio = supported.ratios.length && !supported.ratios.includes(normalizeVideoRatioValue(current.ratio)) ? supported.ratios[0] : current.ratio;
const executableResolutions = supported.resolutions.filter(value => ["480p", "720p", "1080p"].includes(value.toLowerCase()));
const resolution = executableResolutions.length && !executableResolutions.includes(normalizeVideoResolutionValue(current.resolution)) ? executableResolutions[0].toUpperCase() : current.resolution;
const duration = supported.durations.length && !supported.durations.includes(normalizeVideoDurationValue(current.duration)) ? `${supported.durations[0]}s` : current.duration;
const durations = getCanvasVideoParameters(target, activeMode, resolution || "720P").durations;
const duration = durations.length && !durations.includes(normalizeVideoDurationValue(current.duration)) ? `${durations[0]}s` : current.duration;
const audio = supported.supportsAudio ? current.audio : "关闭";
return ratio === current.ratio && resolution === current.resolution && duration === current.duration && audio === current.audio ? current : {...current, ratio, resolution, duration, audio};
});
@ -17929,7 +17930,7 @@ function VideoParameterEditor({
const candidates = filterCanvasModels(modelOptions, audioRequired ? "audio-video" : "video", mode);
const model = candidates.find(item => item.id === settings.model || item.modelId === settings.model) ||
(!normalizeModelRef(settings.model) || settings.model === "auto" ? candidates[0] : undefined);
const options = getCanvasVideoParameters(model, mode);
const options = getCanvasVideoParameters(model, mode, settings.resolution || "720P");
const executableResolutions = options.resolutions.filter(value => ["480p", "720p", "1080p"].includes(value.toLowerCase())).map(value => value.toUpperCase());
const durationIndex = Math.max(0, options.durations.indexOf(normalizeVideoDurationValue(settings.duration)));
return (

View File

@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import { ChevronDown, ChevronUp, Link2, Scan, SlidersHorizontal, Sparkles } from "lucide-react";
import { getGrsaiGptImageOutputSize } from "@/lib/ai/grsai-gpt-image-sizes";
import { resolveVip98kImageTaskSize } from "@/lib/ai/vip98k-task-invocation";
import { getVip98kQualityOptions, resolveVip98kImageTaskSize, type Vip98kTaskInvocation } from "@/lib/ai/vip98k-task-invocation";
import { cn } from "@/lib/utils";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
@ -268,6 +268,17 @@ export function ImageParamsBar({
availableAspectRatioOptions[0]?.value ||
"1:1";
const declaredQualityOptions = providerType === "vip98k"
? getVip98kQualityOptions((imageGenConfig?.vip98k?.invocation as Vip98kTaskInvocation | undefined)?.inputSchema)
: undefined;
const qualityOptions = ([
{ label: "自动", value: "auto" },
{ label: "高", value: "high" },
{ label: "中", value: "medium" },
{ label: "低", value: "low" },
] as const).filter(option => declaredQualityOptions === undefined ||
(declaredQualityOptions.length ? declaredQualityOptions.includes(option.value) : option.value === "auto"));
const clampParamsByProvider = (raw: ImageGenerationParams): ImageGenerationParams => {
const options = getImageCountOptions();
const fallbackCount = options[0] ?? 1;
@ -286,6 +297,7 @@ export function ImageParamsBar({
aspectRatio,
imageSize,
imageCount,
quality: qualityOptions.some(option => option.value === raw.quality) ? raw.quality : qualityOptions[0]?.value || "auto",
};
};
@ -322,12 +334,6 @@ export function ImageParamsBar({
...buildBaseParams(initialParams),
});
const [minimalParamsOpen, setMinimalParamsOpen] = useState(false);
const qualityOptions = [
{ label: "自动", value: "auto" },
{ label: "高", value: "high" },
{ label: "中", value: "medium" },
{ label: "低", value: "low" },
] as const;
const qualityLabel =
qualityOptions.find((option) => option.value === params.quality)?.label || "中";

View File

@ -0,0 +1,118 @@
# 生效模型参数核对(2026-11-16)
核对对象为模型和所属上游同时启用的 76 条配置,包括隐藏但仍可被功能调用的模型。依据生产配置快照、实际请求构建代码、98K 当前账户公布的接口契约以及阿里云、AtlasCloud、Anthropic 官方资料。
## 修复范围
| 问题 | 影响与处理 |
| --- | --- |
| 图片尺寸与比例 | 删除仅允许正方形的错误约束;有独立比例与清晰度字段时按上游契约组合,固定 2K/4K 模型使用对应档位。 |
| 请求路线 | 显式选定的标准接口优先于通用任务示例,保留路线与参数约束的对应关系。 |
| 参考图数量 | 读取嵌套约束并采用当前实际调用接口的上限,GPT Image 2 的上限由 16 校正为 14。 |
| 图片质量与负面提示词 | 质量和负面提示词只写入一个有效位置;固定质量模型不再发送旧的其他档位,页面只提供接口接受的质量选项。 |
| 可选生成控制 | 修复水印、提示词扩展、随机种子、尾帧和固定镜头的已支持字段漏传,保留 false 和 0 的原值;上游未声明的字段不发送。 |
| 视频时长 | Veo 使用当前接口的 duration 字段;Minimax 的 1080p 时长选项限制在接口允许范围内。 |
| 文字输出长度 | AI SDK 调用统一使用 maxOutputTokens,原生厂商接口保留各自标准字段。 |
| Claude 采样参数 | 对固定采样协议移除 temperature、top_p、top_k,保留工具调用和输出长度。Haiku 5.5 已实测。 |
| 世界生成分类 | world-generation 的类型及任务调用配置按现有世界生成接口校正,避免作为聊天模型使用。 |
## 验证
- 图片、视频、音频及工具参数组成 12,135 个离线请求用例,采用实际请求构建函数,并核对当前接口约束与字段值。
- 阿里云图片另外覆盖 80 个尺寸、数量、参考图、随机种子和开关组合;7 个 AtlasCloud 三维模型按各自 OpenAPI 请求规范核对。
- 19 个聊天/文字模型捕获官方 SDK 生成的请求,覆盖输出长度、采样、停止词以及适用的图片和工具调用。13 个 98K 模型同时通过当前路线契约校验;其余 6 个根据接入代码和 SDK 请求核对。
- 自动回归 118 项通过,TypeScript 检查通过。
- 独立实测:Nano Banana 2 带参考图生成 16:9 图片,返回 1376×768 PNG;固定 4K 编辑返回 4096×4096 JPEG;Claude Haiku 5.5 返回有效工具调用。两张图片均完成七牛保存和下载验证。每项只有一次提交。
## 生效模型清单
| 模型 | 上游 | 本次核对 |
| --- | --- | --- |
| `grok-4.7` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `gpt-image-2` | 98K | 126 组请求字段与接口约束 |
| `gpt-image-2-vip` | 98K | 360 组请求字段与接口约束 |
| `nano-banana-2` | 98K | 90 组请求字段与接口约束 |
| `nano-banana-pro` | 98K | 90 组请求字段与接口约束 |
| `gpt-image-2.5` | 98K | 30 组请求字段与接口约束 |
| `gpt-image-2.5-flare` | 98K | 288 组请求字段与接口约束 |
| `ocr` | 98K | 3 组请求字段与接口约束 |
| `gpt-image-2.5-sunburst` | 98K | 504 组请求字段与接口约束 |
| `nano-banana-2-2k-cl` | 98K | 12 组请求字段与接口约束 |
| `nano-banana-2-4k-cl` | 98K | 12 组请求字段与接口约束 |
| `nano-banana-2-cl` | 98K | 12 组请求字段与接口约束 |
| `nano-banana-pro-4k-vip` | 98K | 12 组请求字段与接口约束 |
| `nano-banana-pro-cl` | 98K | 12 组请求字段与接口约束 |
| `nano-banana-pro-vip` | 98K | 12 组请求字段与接口约束 |
| `doubao-seedream-5-0-pro` | 98K | 240 组请求字段与接口约束 |
| `flux-2-pro` | 98K | 48 组请求字段与接口约束 |
| `gpt-image-2.6` | 98K | 84 组请求字段与接口约束 |
| `gpt-image-2.6-flare` | 98K | 360 组请求字段与接口约束 |
| `gpt-image-2.6-sunburst` | 98K | 36 组请求字段与接口约束 |
| `nano-banana-2-plus` | 98K | 360 组请求字段与接口约束 |
| `nano-banana-pro-plus` | 98K | 360 组请求字段与接口约束 |
| `qwen-image-3.0` | 98K | 48 组请求字段与接口约束 |
| `qwen-image-3.0-pro` | 98K | 48 组请求字段与接口约束 |
| `minimax-h3` | 98K | 320 组请求字段与接口约束 |
| `veo-3.1-fast` | 98K | 16 组请求字段与接口约束 |
| `seedance-2.5` | 98K | 1296 组请求字段与接口约束 |
| `seedance-2.5-image-to-video` | 98K | 1458 组请求字段与接口约束 |
| `seedance-2.5-reference-to-video` | 98K | 1458 组请求字段与接口约束 |
| `seedance-2.5-text-to-video` | 98K | 1134 组请求字段与接口约束 |
| `gemini-omni-1.1-flash-preview` | 98K | 8 组请求字段与接口约束 |
| `grok-imagine-video` | 98K | 2500 组请求字段与接口约束 |
| `grok-imagine-video-1.5` | 98K | 750 组请求字段与接口约束 |
| `gemini-3.8-flash` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `gpt-6-astra` | 98K | SDK 请求、输出长度、采样、停止词 |
| `gpt-6-sol` | 98K | SDK 请求、输出长度、采样、停止词 |
| `gpt-6.1-sol` | 98K | SDK 请求、输出长度、采样、停止词 |
| `world-generation` | 98K | 世界生成类型、任务提交与结果查询配置 |
| `claude-haiku-5-5` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `claude-sonnet-4-6` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `image-expansion` | 98K | 3 组请求字段与接口约束 |
| `gem-3.1-tts` | 98K | 4 组请求字段与接口约束 |
| `mimo-v2.5-asr` | 98K | 1 组请求字段与接口约束 |
| `mimo-v2.5-tts` | 98K | 1 组请求字段与接口约束 |
| `mimo-v2.5-tts-voiceclone` | 98K | 1 组请求字段与接口约束 |
| `mimo-v2.5-tts-voicedesign` | 98K | 1 组请求字段与接口约束 |
| `music-2.5` | 98K | 3 组请求字段与接口约束 |
| `music-2.5+` | 98K | 3 组请求字段与接口约束 |
| `speech-2.8-hd` | 98K | 6 组请求字段与接口约束 |
| `speech-2.8-turbo` | 98K | 6 组请求字段与接口约束 |
| `suno-v4.5` | 98K | 3 组请求字段与接口约束 |
| `suno-v6` | 98K | 3 组请求字段与接口约束 |
| `suno-v5` | 98K | 3 组请求字段与接口约束 |
| `suno-v5-5` | 98K | 3 组请求字段与接口约束 |
| `claude-fable-5-1` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `claude-opus-5-5` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `claude-sonnet-5-5` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `gemini-4-argon` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `grok-4.5` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `grok-4.6` | 98K | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `tripo-h3.1/image-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `tripo-h3.1/text-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `tencent/hunyuan3d-pro/text-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `tencent/hunyuan3d-pro/image-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `tencent/hunyuan3d-rapid/text-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `tencent/hunyuan3d-rapid/image-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `bytedance/seed3d-v2.0/image-to-3d` | AtlasCloud | 提示词/参考图、三维输出参数及官方 OpenAPI |
| `qwen-image-3.0` | 阿里云图片 | 80 组图片参数及原生请求字段 |
| `qwen3-vl-plus` | 阿里云 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `qwen3.8-max` | 阿里云 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `qwen3.8-omni-flash` | 阿里云 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `qwen3-tts-instruct-flash` | 阿里云 | 官方语音请求、音色、语言与指令 |
| `qwen3-tts-flash` | 阿里云 | 官方语音请求、音色、语言与指令 |
| `deepseek-flash` | 自定义标准接口 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `agnes-1.5-flash` | 自定义标准接口 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
| `agnes-2.0-flash` | 自定义标准接口 | SDK 请求、输出长度、采样、停止词、视觉及工具调用 |
## 已知问题与验证边界
- 场景融合的首选模型配置指向一个视频模型,当前实现会排除该项并使用图片候选模型,因此实际没有将图片请求提交给视频接口;该首选配置尚未调整。
- 离线参数核对不等于 76 个模型逐个完成付费生成,也不证明上游持续可用、效果或速度;实际生成验证范围为上述三项。
- 自动选模时页面尚未确定最终模型,接入层仍须依据实际选中接口规范化固定参数。模型清单和接口约束会随上游调整,本报告对应本次核对时点。
## 资料
- [Anthropic Haiku 5.5 采样参数迁移说明](https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide#remove-sampling-parameters)
- [阿里云图片生成及编辑接口](https://www.alibabacloud.com/help/en/model-studio/qwen-image-generation-and-editing-api-reference)
- [阿里云语音合成接口](https://www.alibabacloud.com/help/en/model-studio/qwen-tts-api)

View File

@ -185,7 +185,7 @@ async function optimizeWithConfiguredQwenVisionModel(params: {
},
],
temperature: 0,
maxTokens: 320,
maxOutputTokens: 320,
abortSignal: AbortSignal.timeout(30_000),
} as any);

View File

@ -124,7 +124,7 @@ async function analyzeWithConfiguredQwenVisionModel(params: {
},
],
temperature: 0,
maxTokens: 220,
maxOutputTokens: 220,
abortSignal: AbortSignal.timeout(25_000),
} as any);

View File

@ -1737,7 +1737,7 @@ async function buildExecutionPlanWithAgent(
.filter(Boolean)
.join("\n\n"),
temperature: getCompatibleTextGenerationTemperature(plannerModelConfig, 0.1),
maxTokens: 420,
maxOutputTokens: 420,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);
@ -1858,7 +1858,7 @@ async function generateAgentConversation(
},
],
temperature: getCompatibleTextGenerationTemperature(visionModelConfig, 0.2),
maxTokens: 360,
maxOutputTokens: 360,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);
@ -1920,7 +1920,7 @@ async function generateAgentConversation(
system: systemPrompt,
prompt,
temperature: getCompatibleTextGenerationTemperature(reasoningModelConfig, 0.35),
maxTokens: 520,
maxOutputTokens: 520,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);
@ -2002,7 +2002,7 @@ async function recommendImageParamsWithAgent(
- negativePrompt 仅在明显需要避坑时填写。`,
prompt: requestText,
temperature: getCompatibleTextGenerationTemperature(plannerModelConfig, 0.15),
maxTokens: 220,
maxOutputTokens: 220,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);
@ -2095,7 +2095,7 @@ async function recommendVideoPlanWithAgent(
- 避免抽象空话,必须可执行。`,
prompt,
temperature: getCompatibleTextGenerationTemperature(plannerModelConfig, 0.2),
maxTokens: 720,
maxOutputTokens: 720,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);
@ -2175,7 +2175,7 @@ async function refineRouteWithAgent(
候选模型:
${candidatesText}`,
temperature: getCompatibleTextGenerationTemperature(plannerModelConfig, 0.1),
maxTokens: 120,
maxOutputTokens: 120,
abortSignal: AbortSignal.timeout(AGENT_OPERATION_TIMEOUT_MS),
} as any);

View File

@ -7,7 +7,7 @@ export type DetailKimiPurpose = "plan" | "preflight" | "review" | "repair";
export type DetailKimiGenerateOptions = {
temperature?: number;
topP?: number;
maxTokens?: number;
maxOutputTokens?: number;
headers?: Record<string, string>;
};
@ -80,7 +80,7 @@ export function buildDetailKimiGenerateOptions(params: {
return {
temperature: thinking === "enabled" ? 1 : 0.6,
topP: 0.95,
maxTokens: getPurposeMaxTokens(params),
maxOutputTokens: getPurposeMaxTokens(params),
headers: {
[DETAIL_KIMI_THINKING_HEADER]: thinking,
[DETAIL_KIMI_PROFILE_HEADER]: `detail-ui-${params.purpose}`,

View File

@ -687,7 +687,7 @@ export async function optimizePromptWithLLM(params: {
system: optimizerSystemPrompt,
prompt: finalUserMessage,
temperature: getCompatibleTextGenerationTemperature(selectedOptimizerModel, 0.2),
maxTokens: 200,
maxOutputTokens: 200,
abortSignal: AbortSignal.timeout(12_000),
} as any);

View File

@ -153,28 +153,30 @@ export function createVip98kChatModel(params: {
(!metadata.chatInvocation && invocation.protocol === "anthropic-messages"));
const resolveModel = async (signal?: AbortSignal) => {
signal?.throwIfAborted();
if (!needsDiscovery) return model;
if (!needsDiscovery) return { model, contract: invocation };
const models = await awaitWithAbort(discoverContracts(root, baseFetch), signal);
const contract = selectVip98kChatInvocation(models.get(params.modelId));
if (!contract) throw new Error("VIP98K 此模型未公布兼容的对话接口,请核对模型类型和接口配置。");
return createModel(contract);
return { model: createModel(contract), contract };
};
const callOptions = (options: LanguageModelV2CallOptions, contract: typeof invocation) =>
contract?.omitSampling ? { ...options, temperature: undefined, topP: undefined, topK: undefined } : options;
return {
specificationVersion: model.specificationVersion,
provider: model.provider,
modelId: model.modelId,
supportedUrls: model.supportedUrls,
async doGenerate(options) {
const activeModel = await resolveModel(options.abortSignal);
const result = await activeModel.doGenerate(options);
const active = await resolveModel(options.abortSignal);
const result = await active.model.doGenerate(callOptions(options, active.contract));
if (requiresToolCall(options) && !result.content.some((part) => part.type === "tool-call")) throw missingToolError();
if (!result.content.some((part) => part.type === "tool-call" ||
(part.type === "text" && part.text.trim()))) throw emptyResponseError();
return result;
},
async doStream(options) {
const activeModel = await resolveModel(options.abortSignal);
const result = await activeModel.doStream(options);
const active = await resolveModel(options.abortSignal);
const result = await active.model.doStream(callOptions(options, active.contract));
let usable = false;
let toolCalled = false;
let failed = false;

View File

@ -28,6 +28,8 @@ import {
normalizeVip98kInvocationHeaders,
resolveVip98kImageTaskSize,
selectVip98kTaskInvocation,
vip98kReferenceLimit,
getVip98kQualityOptions,
type Vip98kTaskInvocation,
} from "@/lib/ai/vip98k-task-invocation";
import { VIP98K_BASE_URL, normalizeVip98kBaseUrl } from "@/lib/ai/vip98k-models";
@ -1574,6 +1576,14 @@ export function buildTaskBody(params: Vip98kTaskParams, invocation: Vip98kInvoca
const imageParams = params.imageParams || {};
const promptTitle = params.prompt.split(/\s+/).slice(0, 8).join(" ").slice(0, 80);
const body: Record<string, unknown> = { ...(invocation?.requestExample || {}) };
if (toRecord(body.metadata)) body.metadata = { ...toRecord(body.metadata)! };
const setField = (key: string, value: unknown) => {
const metadata = toRecord(body.metadata);
if (metadata && key in metadata) {
metadata[key] = value;
delete body[key];
} else body[key] = value;
};
if ("model" in body || !invocation) body.model = params.modelId;
if ("displayName" in body || !invocation) {
body.displayName = promptTitle || params.modelId;
@ -1652,11 +1662,31 @@ export function buildTaskBody(params: Vip98kTaskParams, invocation: Vip98kInvoca
}
}
if (negativePrompt) {
if ("negativePrompt" in body || !invocation) body.negativePrompt = negativePrompt;
if ("negative_prompt" in body || !invocation) body.negative_prompt = negativePrompt;
const key = ["negative_prompt", "negativePrompt"].find(key =>
invocationSupportsBodyField(invocation, key));
if (key) {
const other = key === "negative_prompt" ? "negativePrompt" : "negative_prompt";
delete body[other];
if (toRecord(body.metadata)) delete (body.metadata as Record<string, unknown>)[other];
setField(key, negativePrompt);
}
}
if (quality && invocationSupportsBodyField(invocation, "quality")) {
body.quality = quality;
const options = getVip98kQualityOptions(invocation?.inputSchema);
const effectiveQuality = options?.length === 1 ? options[0] : quality;
if (options?.length && !options.includes(effectiveQuality)) throw Error("当前模型不支持所选图片质量,请重新选择");
setField("quality", effectiveQuality);
}
const generationParamAliases = [
["seed", "seed"],
["watermark", "watermark"],
["promptExtend", "prompt_extend"],
["cameraFixed", "camera_fixed"],
["returnLastFrame", "return_last_frame"],
] as const;
for (const [sourceKey, targetKey] of generationParamAliases) {
const value = params.kind === "video" ? videoParams[sourceKey] : imageParams[sourceKey];
if (value !== undefined && invocationSupportsBodyField(invocation, targetKey)) setField(targetKey, value);
}
const imageToolParamAliases = [
["scaleFactor", "scale_factor"],
@ -1698,9 +1728,8 @@ export function buildTaskBody(params: Vip98kTaskParams, invocation: Vip98kInvoca
delete body.size;
}
const imageBindingKeys = bindVip98kImages(body, params.imageUrls, invocation?.inputSchema);
const imageProperties = toRecord(invocation?.inputSchema?.properties) || {};
for (const key of imageBindingKeys) {
const limit = toRecord(imageProperties[key])?.maxItems;
const limit = vip98kReferenceLimit(invocation?.inputSchema, key);
if (typeof limit === "number" && params.imageUrls.length > limit) throw Error(`当前模型最多支持 ${limit} 张参考图`);
}
if (params.imageUrls.length > 0 && !invocation && imageBindingKeys.length === 0) {
@ -1759,13 +1788,18 @@ export function buildTaskBody(params: Vip98kTaskParams, invocation: Vip98kInvoca
}) : [];
const selectedRatio = aspectRatio || "1:1";
if (ratios.includes(selectedRatio)) body.size = selectedRatio;
else if (sizes?.includes(resolution) && hasNativeAspectRatio) body.size = resolution;
else if (pixels.length && (resolution || aspectRatio)) {
const [rw, rh] = selectedRatio.split(":").map(Number);
const matching = pixels.filter(size => Math.abs(size.width / size.height - rw / rh) < 0.025);
if (!matching.length) throw Error("当前模型不支持所选图片比例");
const area = resolution === "4K" ? 4096 ** 2 : resolution === "2K" ? 2048 ** 2 : 1024 ** 2;
matching.sort((a, b) => Math.abs(a.width * a.height - area) - Math.abs(b.width * b.height - area));
body.size = matching[0].size;
if (!matching.length && sizes?.includes("auto") && hasNativeAspectRatio && hasNativeResolution) {
body.size = "auto";
} else {
if (!matching.length) throw Error("当前模型不支持所选图片比例");
const area = resolution === "4K" ? 4096 ** 2 : resolution === "2K" ? 2048 ** 2 : 1024 ** 2;
matching.sort((a, b) => Math.abs(a.width * a.height - area) - Math.abs(b.width * b.height - area));
body.size = matching[0].size;
}
}
if (ratios.length || pixels.length) {
const suffix = "\n\n[Output constraints]";

View File

@ -55,7 +55,7 @@ export async function buildDirectAgentImageAnalysisAnswer(params: {
"请用中文直接回答,不要复述“根据摘要/根据图片”,也不要输出多余寒暄。",
].join("\n\n"),
temperature: 0.2,
maxTokens: 320,
maxOutputTokens: 320,
abortSignal: AbortSignal.timeout(20_000),
} as any);

View File

@ -1624,7 +1624,7 @@ export async function summarizeImageForExecutionReport(params: {
...(compatibleTemperature !== undefined
? { temperature: compatibleTemperature }
: {}),
maxTokens: 120,
maxOutputTokens: 120,
abortSignal: AbortSignal.timeout(attemptTimeoutMs),
} as any);
@ -2251,7 +2251,7 @@ ${historyText}
},
],
...(analyzerTemperature !== undefined ? { temperature: analyzerTemperature } : {}),
maxTokens: 360,
maxOutputTokens: 360,
abortSignal: AbortSignal.timeout(ANALYZER_TIMEOUT_MS),
}
: {
@ -2259,7 +2259,7 @@ ${historyText}
system: ANALYZER_SYSTEM_PROMPT,
prompt: userMessage,
...(analyzerTemperature !== undefined ? { temperature: analyzerTemperature } : {}),
maxTokens: 300,
maxOutputTokens: 300,
abortSignal: AbortSignal.timeout(ANALYZER_TIMEOUT_MS),
};

View File

@ -5,6 +5,7 @@ export type Vip98kChatInvocation = {
protocol: "openai-chat" | "openai-responses" | "anthropic-messages";
path: "/v1/chat/completions" | "/v1/responses" | "/v1/messages";
headers: Record<string, string>;
omitSampling?: boolean;
};
function record(value: unknown): RecordValue | null {
@ -56,10 +57,18 @@ export function selectVip98kChatInvocation(value: unknown): Vip98kChatInvocation
});
const selected = candidates[0];
if (!selected) return null;
const selectedRoute = getVip98kInvocationHeaders(selected.headers)["X-Relay-Route-Option"];
const schemaSource = candidates.find(candidate => candidate.path === selected.path &&
getVip98kInvocationHeaders(candidate.headers)["X-Relay-Route-Option"] === selectedRoute &&
(candidate.input_schema || candidate.inputSchema));
const properties = record(record(schemaSource?.input_schema || schemaSource?.inputSchema)?.properties);
const fixedSampling = selected.omitSampling === true || ["temperature", "top_p"].some(key =>
record(properties?.[key])?.const !== undefined);
return {
protocol: selected.path === "/v1/messages" ? "anthropic-messages" : selected.path === "/v1/responses" ? "openai-responses" : "openai-chat",
path: selected.path as Vip98kChatInvocation["path"],
headers: getVip98kInvocationHeaders(selected.headers),
...(fixedSampling ? { omitSampling: true } : {}),
};
}

View File

@ -5,6 +5,8 @@ import {
hasVerifiedVip98kOpenAiImageArrayContract,
normalizeVip98kInvocationHeaders,
getVip98kImageBindingKeys,
vip98kReferenceLimit,
selectVip98kTaskInvocation,
} from "@/lib/ai/vip98k-task-invocation";
import { selectVip98kChatInvocation, vip98kChatSupportsVision } from "./vip98k-chat-contract";
@ -568,7 +570,7 @@ function getSupportedImageSizes(model: Vip98kCatalogModel) {
}
const primary = toRecord(toRecord(model.invocation?.input_schema)?.properties) || {};
const resolutionEnum = parseStringArray(toRecord(primary.resolution)?.enum);
if (resolutionEnum.length) return resolutionEnum.map(normalizeImageSize).filter((size): size is string => Boolean(size));
if (resolutionEnum.length) return [...new Set(resolutionEnum.map(normalizeImageSize).filter((size): size is string => Boolean(size)))];
const schemaSizes = getInvocationCandidates(model).flatMap((invocation) => {
const properties =
toRecord(toRecord(invocation.input_schema)?.properties) || {};
@ -752,7 +754,11 @@ function createImagePreset(
"ratio",
"aspect-ratio",
].some((key) => invocationKeys.has(key)) || hasVerifiedVip98kOpenAiImageArrayContract(modelId);
const supportsQuality = invocationKeys.has("quality");
const supportsQuality = getInvocationCandidates(model).some(invocation => {
const field = toRecord(toRecord(invocation.input_schema)?.properties)?.quality;
return field !== false && Boolean(field || invocation.request_example?.quality !== undefined) &&
!toRecord(field)?.const;
});
// Flare repeatedly returns 3:4/4:3 for 4:5/5:4, even with aspect_ratio supplied.
const declaredRatios = getInvocationCandidates(model).flatMap(invocation => {
const props = toRecord(toRecord(invocation.input_schema)?.properties) || {};
@ -767,14 +773,17 @@ function createImagePreset(
: []),
...(supportsReferenceImages ? ["image-to-image", "reference-images"] : []),
];
const declaredReferenceLimits = getInvocationCandidates(model).flatMap(invocation => {
const properties = toRecord(toRecord(invocation.input_schema)?.properties) || {};
return ["file_urls", "image", "images", "reference_images"].flatMap(key => {
const limit = toRecord(properties[key])?.maxItems;
return typeof limit === "number" && limit > 0 ? [limit] : [];
});
const metadata = getVip98kMetadata(model, "image");
const referenceInvocation = selectVip98kTaskInvocation({
modelId, kind: "image", imageCount: 1,
configuredInvocation: metadata.invocation,
configuredInvocations: metadata.invocations,
});
const maxReferenceImages = declaredReferenceLimits.length ? Math.max(...declaredReferenceLimits) : supportsMultiImageReference
const declaredReferenceLimits = getVip98kImageBindingKeys(referenceInvocation).flatMap(key => {
const limit = vip98kReferenceLimit(referenceInvocation?.inputSchema, key);
return typeof limit === "number" && limit > 0 ? [limit] : [];
});
const maxReferenceImages = declaredReferenceLimits.length ? Math.min(...declaredReferenceLimits) : supportsMultiImageReference
? 8
: supportsReferenceImages
? 1
@ -805,7 +814,7 @@ function createImagePreset(
supportedAspectRatios,
supportsMultiImageReference,
maxReferenceImages,
vip98k: getVip98kMetadata(model, "image"),
vip98k: metadata,
},
defaultParams: {
provider: "vip98k",
@ -841,7 +850,7 @@ function createImagePreset(
},
enableLoadingPlaceholder: true,
loadingColor: "yellow",
vip98k: getVip98kMetadata(model, "image"),
vip98k: metadata,
},
sortOrder: TYPE_SORT_ORDER.image + index,
};

View File

@ -316,6 +316,32 @@ function scoreReferenceInvocation(invocation: Vip98kTaskInvocation) {
return score;
}
export function vip98kReferenceLimit(schema: unknown, key: string): number | undefined {
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return;
const current = schema as Record<string, any>;
const limits: number[] = [];
const visitField = (field: any) => {
if (!field || typeof field !== "object") return;
if (typeof field.maxItems === "number") limits.push(field.maxItems);
for (const child of Array.isArray(field.allOf) ? field.allOf : []) visitField(child);
};
visitField(current.properties?.[key]);
for (const child of Array.isArray(current.allOf) ? current.allOf : []) {
const limit = vip98kReferenceLimit(child, key);
if (limit !== undefined) limits.push(limit);
}
return limits.length ? Math.min(...limits) : undefined;
}
export function getVip98kQualityOptions(schema: Record<string, unknown> | null | undefined): string[] | undefined {
const field = (schema?.properties as Record<string, unknown> | undefined)?.quality;
if (field === false) return [];
if (!field || typeof field !== "object") return undefined;
const quality = field as Record<string, unknown>;
if (typeof quality.const === "string") return [quality.const];
return Array.isArray(quality.enum) ? quality.enum.filter((value): value is string => typeof value === "string") : undefined;
}
export function encodeVip98kTaskBody(body: Record<string, unknown>, contentType?: string | null): { body: string | FormData; headers: Record<string, string> } {
if (contentType?.split(";", 1)[0].trim() !== "multipart/form-data") {
return { body: JSON.stringify(body), headers: { "Content-Type": contentType || "application/json" } };
@ -356,14 +382,22 @@ export function selectVip98kTaskInvocation(params: {
);
if ((params.imageCount || 0) > 0) {
const referenceInvocation = candidates
.filter(invocationSupportsVip98kImages)
const references = candidates.filter(invocationSupportsVip98kImages);
const routedReferences = references.filter(candidate =>
getVip98kInvocationHeaders(candidate.headers)["X-Relay-Route-Option"]);
const referenceInvocation = (routedReferences.length ? routedReferences : references)
.sort((a, b) => scoreReferenceInvocation(b) - scoreReferenceInvocation(a))[0];
if (referenceInvocation) {
return resolveVip98kTaskInvocation(params.modelId, referenceInvocation);
}
}
if (params.configuredInvocation &&
getVip98kInvocationHeaders(params.configuredInvocation.headers)["X-Relay-Route-Option"] &&
!params.configuredInvocation.path.includes(":generateContent")) {
return resolveVip98kTaskInvocation(params.modelId, params.configuredInvocation);
}
if (params.kind === "image" && !params.imageCount) {
const textImageTask = candidates.find(candidate => {
const properties = candidate.inputSchema?.properties as Record<string, unknown> | undefined;
@ -449,7 +483,6 @@ function createVerifiedOpenAiImageInvocation(modelId: string) {
function addVerifiedOpenAiImageFields(
invocation: Vip98kTaskInvocation,
modelId: string,
): Vip98kTaskInvocation {
const inputSchema = invocation.inputSchema || {};
const properties =
@ -468,16 +501,8 @@ function addVerifiedOpenAiImageFields(
...inputSchema,
properties: {
...properties,
image: { items: { type: "string" }, type: "array" },
aspect_ratio: { type: "string" },
...(hasVerifiedVip98kGptImage25ResolutionTiers(modelId)
? {
size: {
enum: ["1024x1024", "2048x2048", "2880x2880"],
type: "string",
},
}
: {}),
image: properties.image ?? { items: { type: "string" }, type: "array" },
aspect_ratio: properties.aspect_ratio ?? { type: "string" },
},
},
};
@ -499,7 +524,7 @@ export function resolveVip98kTaskInvocation(
invocationTargetsModel(configuredInvocation, normalizedModelId)
? configuredInvocation
: createVerifiedOpenAiImageInvocation(modelId);
return addVerifiedOpenAiImageFields(invocation, normalizedModelId);
return addVerifiedOpenAiImageFields(invocation);
}
const processingRequest = KNOWN_IMAGE_PROCESSING_TOOL_REQUESTS[normalizedModelId];
if (processingRequest) {

View File

@ -259,7 +259,7 @@ async function interpretStoryboardCommandWithLLM(params: {
.filter(Boolean)
.join("\n\n"),
temperature: 0.1,
maxTokens: 200,
maxOutputTokens: 200,
abortSignal: AbortSignal.timeout(12000),
} as any);

View File

@ -86,7 +86,7 @@ export function filterCanvasModels<T extends CanvasModelDescriptor>(
});
}
export function getCanvasVideoParameters(model: CanvasModelDescriptor | undefined, mode?: VideoGenerationMode) {
export function getCanvasVideoParameters(model: CanvasModelDescriptor | undefined, mode?: VideoGenerationMode, resolution?: string) {
const caps = record(model?.capabilities);
const scoped = record(record(caps.modeConstraints || caps.constraints)[mode || ""]);
const strings = (value: unknown) => Array.isArray(value) ? [...new Set(value.map(String).filter(Boolean))] : [];
@ -94,11 +94,15 @@ export function getCanvasVideoParameters(model: CanvasModelDescriptor | undefine
const min = Number(durationRange.min), max = Number(durationRange.max);
const configured = record((model as CanvasModelDescriptor & {imageGenConfig?: unknown})?.imageGenConfig).videoDurationOptions;
const durations = Array.isArray(scoped.durationOptions) ? scoped.durationOptions : Array.isArray(configured) && configured.length ? configured : caps.durationOptions;
const durationValues = Array.isArray(durations) ? [...new Set(durations.map(Number).filter(n => Number.isFinite(n) && n > 0))].sort((a,b) => a-b) :
min > 0 && max >= min && max-min <= 120 ? Array.from({length: max-min+1}, (_,i) => min+i) : [];
const bounds = model?.providerType === "vip98k" && resolution
? vip98kVideoDurationBounds(record(caps.vip98k).invocation?.inputSchema, resolution.toLowerCase())
: { min: 0, max: Infinity, durations: undefined };
return {
ratios: strings(scoped.ratioOptions || caps.supportedRatios),
resolutions: strings(scoped.resolutionOptions || caps.supportedResolutions),
durations: Array.isArray(durations) ? [...new Set(durations.map(Number).filter(n => Number.isFinite(n) && n > 0))].sort((a,b) => a-b) :
min > 0 && max >= min && max-min <= 120 ? Array.from({length: max-min+1}, (_,i) => min+i) : [],
durations: durationValues.filter(value => value >= bounds.min && value <= bounds.max && (!bounds.durations || bounds.durations.includes(value))),
supportsAudio: caps.supportGenerateAudio === true || caps.supportsAudio === true || caps.generateAudio === true || strings(record(record(model?.imageGenConfig).atlasCloud).propertyNames).includes("generate_audio"),
};
}

View File

@ -309,3 +309,17 @@ test("a cancelled request can leave shared discovery without submitting a paid P
finishCatalog(Response.json({ data: { sections: [{ models: [catalogModel] }] } }));
expect(posts).toBe(0);
});
test("fixed-sampling native contracts omit sampling controls while preserving tools and token limits", async () => {
let sent: any;
const metadata={chatInvocation:{protocol:'anthropic-messages',path:'/v1/messages',headers:{'X-Relay-Route-Option':'native_route'}},invocation:{kind:'chat',path:'/v1/messages',headers:{'X-Relay-Route-Option':'native_route'},inputSchema:{properties:{temperature:{const:1},top_p:{const:.99},top_k:false}}}};
const selected=selectVip98kChatInvocation(metadata);
expect(selected?.omitSampling).toBe(true);
const nativeModel=createVip98kChatModel({apiKey:'fixture',baseURL:'https://relay.example',modelId:'claude-haiku-5-5',metadata,fetch:async(_url,init)=>{
sent=JSON.parse(String(init?.body));
return Response.json({id:'test',type:'message',role:'assistant',model:'claude-haiku-5-5',content:[{type:'text',text:'ok'}],stop_reason:'end_turn',stop_sequence:null,usage:{input_tokens:1,output_tokens:1}});
}});
await generateText({model:nativeModel,prompt:'test',temperature:.2,topP:.9,topK:4,maxOutputTokens:321,maxRetries:0});
expect(sent.max_tokens).toBe(321);
for(const key of ['temperature','top_p','top_k'])expect(sent).not.toHaveProperty(key);
});

View File

@ -178,3 +178,90 @@ test("completed audio checkpoints retain the original provider and resumable tas
const checkpoint={operation:"audio",provider:"vip98k",modelRef:"test",modelId:"gem-2.5-tts",providerId:"source",baseUrl:"https://relay.example",taskId:"original",url:"https://example.com/audio.wav",format:"wav"};
expect(getAudioCheckpoint({request:{kind:"audio",params:{modelRef:"test"}},result:{upstreamAudio:checkpoint}})).toEqual(checkpoint);
});
test("route-scoped image contracts take precedence over generic task examples", () => {
const selected = {...invocation({size:{type:'string'},image:{type:'array',maxItems:8}}),headers:{'X-Relay-Route-Option':'selected'}};
const generic = {...invocation({resolution:{enum:['1K','2K']},aspect_ratio:{enum:['1:1','16:9']},file_urls:{type:'array'}},{file_urls:[]}),kind:'task',path:'/extensions/v1/tasks'};
for(const imageCount of [0,1]) {
const resolved=selectVip98kTaskInvocation({modelId:'image',kind:'image',configuredInvocation:selected,configuredInvocations:[generic,selected],imageCount});
expect(resolved?.headers).toEqual({'X-Relay-Route-Option':'selected'});
}
});
test("native ratio and resolution contracts can use automatic pixels for non-square images", () => {
const contract=invocation({size:{enum:['auto','1024x1024','2048x2048','4096x4096']},resolution:{enum:['1K','2K','4K']},aspect_ratio:{enum:['1:1','16:9','9:16']}},{size:'1024x1024'});
for(const aspectRatio of ['16:9','9:16'])for(const imageSize of ['1K','2K','4K']) {
const result=buildTaskBody({...params,imageParams:{imageSize,aspectRatio}},contract);
expect(result.body).toMatchObject({size:'auto',resolution:imageSize,aspect_ratio:aspectRatio});
}
});
test("reference limits inside allOf are enforced before submission and during import", () => {
const schema={properties:{model:{type:'string'},prompt:{type:'string'},images:{allOf:[{type:'array',maxItems:16},{maxItems:14}]}}};
const contract={...invocation({},{images:[]}),inputSchema:schema};
const images=Array.from({length:15},(_,i)=>`https://fixture.example/${i}.png`);
expect(()=>buildTaskBody({...params,imageUrls:images},contract)).toThrow('14');
const [model]=buildVip98kModelPresets([{id:'image',type:'image',invocation:{kind:'tool',path:contract.path,input_schema:schema,request_example:contract.requestExample}}]);
expect(model.imageGenConfig?.maxReferenceImages).toBe(14);
});
test("quality and negative prompt have a single effective location", () => {
const metadata={quality:'high'};
const contract=invocation({quality:{const:'high'},negative_prompt:{type:'string'},negativePrompt:{type:'string'}},{metadata,negativePrompt:'example'});
const result=buildTaskBody({...params,imageParams:{quality:'auto',negativePrompt:'blurry'}},contract);
expect(result.body.metadata).toEqual({quality:'high'});
expect(result.body).not.toHaveProperty('quality');
expect(result.body.negative_prompt).toBe('blurry');
expect(result.body).not.toHaveProperty('negativePrompt');
expect(metadata).toEqual({quality:'high'});
});
test("fixed resolution edit contracts determine the imported default", () => {
for(const resolution of ['2K','4K']){
const [model] = buildVip98kModelPresets([{
id: 'fixed-image', type: 'image',
invocation: {
kind: 'tool', path: '/v1/images/generations',
request_example: { model: 'fixed-image', prompt: 'test' },
input_schema: { properties: { size: { type: 'string' } } },
},
invocations: [{
kind: 'tool', path: '/v1/images/edits',
request_example: { model: 'fixed-image', prompt: 'test', file_urls: [] },
input_schema: { properties: {
file_urls: { type: 'array', maxItems: 16 }, size: { enum: ['auto'] },
resolution: { enum: [resolution] }, aspect_ratio: { enum: ['1:1', '16:9'] },
} },
}],
}]);
expect(model.defaultParams.imageSize).toBe(resolution);
expect(model.imageGenConfig?.supportedImageSizes).toEqual([resolution]);
}
});
test("video duration choices follow the selected resolution", () => {
const schema={properties:{duration:{minimum:1,maximum:15}},allOf:[{if:{properties:{resolution:{const:'1080p'}}},then:{properties:{duration:{maximum:10}}}}]};
const model={providerType:'vip98k',capabilities:{kind:'video',durationOptions:[5,10,15],vip98k:{invocation:{inputSchema:schema}}}};
expect(getCanvasVideoParameters(model,'text-to-video','1080P').durations).toEqual([5,10]);
expect(getCanvasVideoParameters(model,'text-to-video','720p').durations).toEqual([5,10,15]);
});
test("generation controls preserve false and zero in the declared wire fields", () => {
const contract=invocation({seed:{type:'integer'},watermark:{type:'boolean'},prompt_extend:{type:'boolean'},return_last_frame:{type:'boolean'},camera_fixed:{type:'boolean'}},{metadata:{watermark:true}});
const image=buildTaskBody({...params,imageParams:{seed:0,watermark:false,promptExtend:false}},contract).body;
expect(image).toMatchObject({seed:0,prompt_extend:false,metadata:{watermark:false}});
expect(image).not.toHaveProperty('watermark');
const video=buildTaskBody({...params,kind:'video',videoParams:{seed:0,watermark:false,returnLastFrame:true,cameraFixed:false}},contract).body;
expect(video).toMatchObject({seed:0,return_last_frame:true,camera_fixed:false,metadata:{watermark:false}});
const unsupported=buildTaskBody({...params,imageParams:{seed:0,watermark:false}},invocation({seed:false,watermark:false})).body;
expect(unsupported).not.toHaveProperty('seed');
expect(unsupported).not.toHaveProperty('watermark');
});
test("fixed quality routes replace stale quality choices before submission", () => {
const contract=invocation({quality:{enum:['auto']}},{quality:'auto'});
for(const quality of ['auto','low','medium','high']) {
expect(buildTaskBody({...params,imageParams:{quality}},contract).body.quality).toBe('auto');
}
expect(()=>buildTaskBody({...params,imageParams:{quality:'invalid'}},invocation({quality:{enum:['low','high']}}))).toThrow('图片质量');
});

View File

@ -970,13 +970,17 @@ test.describe("VIP98K reference-image routing", () => {
properties: {
aspect_ratio: { type: "string" },
image: { type: "array" },
size: {
enum: ["1024x1024", "2048x2048", "2880x2880"],
},
},
});
});
test("Flare retains non-square pixel geometry", () => {
const contract = resolveVip98kTaskInvocation('gpt-image-2.5-flare', null);
const wide = buildTaskBody({apiKey:'fixture',modelId:'gpt-image-2.5-flare',kind:'image',prompt:'wide product',imageUrls:[],videoUrls:[],modelConfig:{},imageParams:{imageSize:'2K',aspectRatio:'16:9'}},contract);
expect(wide.body.size).toBe('2720x1536');
});
test("does not inherit multi-image support from broad authorized metadata", () => {
const presets = buildVip98kModelPresets([
{