fix(ruxa): use configured task input mode for image models
This commit is contained in:
parent
aa6c1f72a6
commit
eb15c7a33b
@ -122,19 +122,22 @@ export function ImageParamsBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getImageCountOptions = () => {
|
const getImageCountOptions = () => {
|
||||||
// RUXA 当前按单图任务处理(优先级最高)
|
if (imageGenConfig?.maxImages) {
|
||||||
|
return Array.from({ length: imageGenConfig.maxImages }, (_, i) => i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (providerType === "ruxa-image") {
|
||||||
|
return [1];
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
providerType === "ruxa-image" ||
|
|
||||||
providerType === "openai-image" ||
|
providerType === "openai-image" ||
|
||||||
providerType === "stepfun-image" ||
|
providerType === "stepfun-image" ||
|
||||||
providerType === "midjourney"
|
providerType === "midjourney"
|
||||||
) {
|
) {
|
||||||
return [1];
|
return [1];
|
||||||
}
|
}
|
||||||
// 优先使用模型配置中的 maxImages
|
|
||||||
if (imageGenConfig?.maxImages) {
|
|
||||||
return Array.from({ length: imageGenConfig.maxImages }, (_, i) => i + 1);
|
|
||||||
}
|
|
||||||
// 否则根据 providerType 判断
|
// 否则根据 providerType 判断
|
||||||
if (providerType === "alibaba-image") {
|
if (providerType === "alibaba-image") {
|
||||||
// 阿里生图:1~6 张(qwen-image-edit-plus)
|
// 阿里生图:1~6 张(qwen-image-edit-plus)
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import "server-only";
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { uploadFile } from "@/lib/storage/service";
|
import { uploadFile } from "@/lib/storage/service";
|
||||||
import {
|
import {
|
||||||
RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID,
|
|
||||||
resolveRuxaImageRuntimeModelId,
|
resolveRuxaImageRuntimeModelId,
|
||||||
} from "@/lib/ai/ruxa-image-models";
|
} from "@/lib/ai/ruxa-image-models";
|
||||||
|
|
||||||
@ -113,10 +112,8 @@ function isResolutionSupported(resolution: string, config?: RuxaImageModelConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resolveRuxaTaskInputMode({
|
function resolveRuxaTaskInputMode({
|
||||||
activeModelId,
|
|
||||||
modelConfig,
|
modelConfig,
|
||||||
}: {
|
}: {
|
||||||
activeModelId: string;
|
|
||||||
modelConfig?: RuxaImageModelConfig | null;
|
modelConfig?: RuxaImageModelConfig | null;
|
||||||
}) {
|
}) {
|
||||||
if (modelConfig?.ruxaTaskInputMode === "size-image") {
|
if (modelConfig?.ruxaTaskInputMode === "size-image") {
|
||||||
@ -127,9 +124,7 @@ function resolveRuxaTaskInputMode({
|
|||||||
return "resolution-based";
|
return "resolution-based";
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeModelId === RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID
|
return "resolution-based";
|
||||||
? "size-image"
|
|
||||||
: "resolution-based";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRuxaTaskInput({
|
function buildRuxaTaskInput({
|
||||||
@ -491,7 +486,6 @@ export function createRuxaImage({ apiKey, baseURL }: RuxaImageConfig) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const taskInputMode = resolveRuxaTaskInputMode({
|
const taskInputMode = resolveRuxaTaskInputMode({
|
||||||
activeModelId,
|
|
||||||
modelConfig: options.imageGenConfig,
|
modelConfig: options.imageGenConfig,
|
||||||
});
|
});
|
||||||
const outputFormat = normalizeOutputFormat(options.imageParams?.outputFormat);
|
const outputFormat = normalizeOutputFormat(options.imageParams?.outputFormat);
|
||||||
@ -517,7 +511,9 @@ export function createRuxaImage({ apiKey, baseURL }: RuxaImageConfig) {
|
|||||||
resolution: input.resolution || null,
|
resolution: input.resolution || null,
|
||||||
aspectRatio: input.aspect_ratio || input.size || null,
|
aspectRatio: input.aspect_ratio || input.size || null,
|
||||||
outputFormat,
|
outputFormat,
|
||||||
|
taskInputMode,
|
||||||
imageInputCount: imageUrls.length,
|
imageInputCount: imageUrls.length,
|
||||||
|
inputKeys: Object.keys(input),
|
||||||
});
|
});
|
||||||
const createResponse = await fetch(createEndpoint, {
|
const createResponse = await fetch(createEndpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export const RUXA_IMAGE_MODEL_PRESETS: RuxaImageModelPreset[] = [
|
|||||||
},
|
},
|
||||||
imageGenConfig: {
|
imageGenConfig: {
|
||||||
...RUXA_IMAGE_CONFIG,
|
...RUXA_IMAGE_CONFIG,
|
||||||
ruxaTaskInputMode: "size-image",
|
ruxaTaskInputMode: "resolution-based",
|
||||||
},
|
},
|
||||||
sortOrder: 10,
|
sortOrder: 10,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -19,7 +19,7 @@ const EXPECTED_MODELS: ModelExpectation[] = [
|
|||||||
modelId: "google/nano-banana-2",
|
modelId: "google/nano-banana-2",
|
||||||
displayName: "nano-banana-2「专线」",
|
displayName: "nano-banana-2「专线」",
|
||||||
expectedRuntimeModelId: RUXA_NANO_BANANA_2_RUNTIME_MODEL_ID,
|
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" },
|
{ modelId: "google/nano-banana-pro", displayName: "nano-banana-pro「专线」", expectedTaskMode: "resolution-based" },
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user