Browse Source

固定展示图片节点生成张数参数

TEST-s
weige 2 months ago
parent
commit
ff9362ce60
  1. 34
      src/components/composer/GenerationComposer.tsx

34
src/components/composer/GenerationComposer.tsx

@ -142,6 +142,7 @@ const COMPOSER_COLLAPSED_WIDTH = 560;
const COMPOSER_EXPANDED_HEIGHT_ESTIMATE = 300; const COMPOSER_EXPANDED_HEIGHT_ESTIMATE = 300;
const COMPOSER_COLLAPSED_HEIGHT_ESTIMATE = 80; const COMPOSER_COLLAPSED_HEIGHT_ESTIMATE = 80;
const IMAGE_COUNT_PARAMETER_NAMES = ["imageCount", "numImages", "num_images", "numOutputs", "num_outputs", "count"]; const IMAGE_COUNT_PARAMETER_NAMES = ["imageCount", "numImages", "num_images", "numOutputs", "num_outputs", "count"];
const DEFAULT_IMAGE_COUNT_OPTIONS: ImageGenerationCount[] = [1, 2, 4];
function findSchemaParameter(schema: ModelParameter[] | undefined, names: string[]): ModelParameter | null { function findSchemaParameter(schema: ModelParameter[] | undefined, names: string[]): ModelParameter | null {
if (!schema || schema.length === 0) return null; if (!schema || schema.length === 0) return null;
@ -1355,9 +1356,15 @@ export function GenerationComposer() {
const imageAspectRatioOptions = getSchemaEnumOptions(activeParameterSchema, ["aspectRatio", "aspect_ratio"]); const imageAspectRatioOptions = getSchemaEnumOptions(activeParameterSchema, ["aspectRatio", "aspect_ratio"]);
const imageResolutionOptions = getSchemaEnumOptions(activeParameterSchema, ["resolution"]); const imageResolutionOptions = getSchemaEnumOptions(activeParameterSchema, ["resolution"]);
const imageCountOptions = getImageCountOptions(activeParameterSchema); const imageCountOptions = getImageCountOptions(activeParameterSchema);
const visibleImageCountOptions = imageCountOptions.length > 0
? imageCountOptions
: DEFAULT_IMAGE_COUNT_OPTIONS;
const imageAspectRatioParameterName = getSchemaParameterName(activeParameterSchema, ["aspectRatio", "aspect_ratio"]); const imageAspectRatioParameterName = getSchemaParameterName(activeParameterSchema, ["aspectRatio", "aspect_ratio"]);
const imageResolutionParameterName = getSchemaParameterName(activeParameterSchema, ["resolution"]); const imageResolutionParameterName = getSchemaParameterName(activeParameterSchema, ["resolution"]);
const imageCountParameterName = getSchemaParameterName(activeParameterSchema, IMAGE_COUNT_PARAMETER_NAMES); const imageCountParameterName = getSchemaParameterName(activeParameterSchema, IMAGE_COUNT_PARAMETER_NAMES);
const selectedImageCountValue = imageCountParameterName
? Number(draft.parameters?.[imageCountParameterName] ?? draft.imageCount)
: draft.imageCount;
const videoDurationOptionsFromSchema = getSchemaEnumOptions(activeParameterSchema, VIDEO_DURATION_PARAMETER_NAMES); const videoDurationOptionsFromSchema = getSchemaEnumOptions(activeParameterSchema, VIDEO_DURATION_PARAMETER_NAMES);
const videoResolutionOptions = getSchemaEnumOptions(activeParameterSchema, ["resolution"]); const videoResolutionOptions = getSchemaEnumOptions(activeParameterSchema, ["resolution"]);
const videoRatioOptions = getSchemaEnumOptions(activeParameterSchema, ["videoRatio"]); const videoRatioOptions = getSchemaEnumOptions(activeParameterSchema, ["videoRatio"]);
@ -2334,21 +2341,26 @@ export function GenerationComposer() {
))} ))}
</select> </select>
)} )}
{imageCountParameterName && imageCountOptions.length > 0 && ( {visibleImageCountOptions.length > 0 && (
<select <select
aria-label={t("composer.imageCount")} aria-label={t("composer.imageCount")}
value={Number(draft.parameters?.[imageCountParameterName] ?? draft.imageCount)} value={selectedImageCountValue}
onChange={(event) => onChange={(event) => {
updateSchemaDraftParameter( const nextImageCount = Number(event.target.value) as ImageGenerationCount;
imageCountParameterName, if (imageCountParameterName) {
Number(event.target.value), updateSchemaDraftParameter(
{ imageCount: Number(event.target.value) as ImageGenerationCount }, imageCountParameterName,
["imageCount"] nextImageCount,
) { imageCount: nextImageCount },
} ["imageCount"]
);
return;
}
markDraft({ imageCount: nextImageCount }, ["imageCount"]);
}}
className="rounded-md border border-transparent bg-transparent px-1.5 py-1 text-neutral-200 outline-none transition-colors hover:border-neutral-700 hover:bg-neutral-700/60" className="rounded-md border border-transparent bg-transparent px-1.5 py-1 text-neutral-200 outline-none transition-colors hover:border-neutral-700 hover:bg-neutral-700/60"
> >
{imageCountOptions.map((count) => ( {visibleImageCountOptions.map((count) => (
<option key={count} value={count} className="bg-neutral-900"> <option key={count} value={count} className="bg-neutral-900">
{t("composer.imageCountOption", { count })} {t("composer.imageCountOption", { count })}
</option> </option>

Loading…
Cancel
Save