fix(ruxa): use configured task input mode for image models

This commit is contained in:
Your Name 2026-06-09 17:11:10 +08:00
parent aa6c1f72a6
commit eb15c7a33b
4 changed files with 14 additions and 15 deletions

View File

@ -122,19 +122,22 @@ export function ImageParamsBar({
};
const getImageCountOptions = () => {
// RUXA 当前按单图任务处理(优先级最高)
if (imageGenConfig?.maxImages) {
return Array.from({ length: imageGenConfig.maxImages }, (_, i) => i + 1);
}
if (providerType === "ruxa-image") {
return [1];
}
if (
providerType === "ruxa-image" ||
providerType === "openai-image" ||
providerType === "stepfun-image" ||
providerType === "midjourney"
) {
return [1];
}
// 优先使用模型配置中的 maxImages
if (imageGenConfig?.maxImages) {
return Array.from({ length: imageGenConfig.maxImages }, (_, i) => i + 1);
}
// 否则根据 providerType 判断
if (providerType === "alibaba-image") {
// 阿里生图:1~6 张(qwen-image-edit-plus)

View File

@ -3,7 +3,6 @@ import "server-only";
import sharp from "sharp";
import { uploadFile } from "@/lib/storage/service";
import {
RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID,
resolveRuxaImageRuntimeModelId,
} from "@/lib/ai/ruxa-image-models";
@ -113,10 +112,8 @@ function isResolutionSupported(resolution: string, config?: RuxaImageModelConfig
}
function resolveRuxaTaskInputMode({
activeModelId,
modelConfig,
}: {
activeModelId: string;
modelConfig?: RuxaImageModelConfig | null;
}) {
if (modelConfig?.ruxaTaskInputMode === "size-image") {
@ -127,9 +124,7 @@ function resolveRuxaTaskInputMode({
return "resolution-based";
}
return activeModelId === RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID
? "size-image"
: "resolution-based";
return "resolution-based";
}
function buildRuxaTaskInput({
@ -491,7 +486,6 @@ export function createRuxaImage({ apiKey, baseURL }: RuxaImageConfig) {
});
}
const taskInputMode = resolveRuxaTaskInputMode({
activeModelId,
modelConfig: options.imageGenConfig,
});
const outputFormat = normalizeOutputFormat(options.imageParams?.outputFormat);
@ -517,7 +511,9 @@ export function createRuxaImage({ apiKey, baseURL }: RuxaImageConfig) {
resolution: input.resolution || null,
aspectRatio: input.aspect_ratio || input.size || null,
outputFormat,
taskInputMode,
imageInputCount: imageUrls.length,
inputKeys: Object.keys(input),
});
const createResponse = await fetch(createEndpoint, {
method: "POST",

View File

@ -45,7 +45,7 @@ export const RUXA_IMAGE_MODEL_PRESETS: RuxaImageModelPreset[] = [
},
imageGenConfig: {
...RUXA_IMAGE_CONFIG,
ruxaTaskInputMode: "size-image",
ruxaTaskInputMode: "resolution-based",
},
sortOrder: 10,
},

View File

@ -19,7 +19,7 @@ const EXPECTED_MODELS: ModelExpectation[] = [
modelId: "google/nano-banana-2",
displayName: "nano-banana-2「专线」",
expectedRuntimeModelId: RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID,
expectedTaskMode: "size-image",
expectedTaskMode: "resolution-based",
},
{ modelId: "google/nano-banana-pro", displayName: "nano-banana-pro「专线」", expectedTaskMode: "resolution-based" },
];