Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/core/shared/ai-asset-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,16 @@ export function truncatePrompt(prompt: string, maxLength = 60): string {
}
return `${prompt.substring(0, maxLength - 3)}...`;
}

/** Asset type → the media kind a generator produces. Folds the legacy aliases onto the unified types. */
export const GENERATION_TYPE: Readonly<Record<string, "image" | "video" | "audio">> = {
image: "image",
video: "video",
audio: "audio",
"text-to-image": "image",
"image-to-video": "video",
"text-to-speech": "audio"
};

/** The legacy speech asset keeps its prompt under `text`. */
export const promptProperty = (asset: { type: string }): "prompt" | "text" => (asset.type === "text-to-speech" ? "text" : "prompt");
13 changes: 1 addition & 12 deletions src/core/ui/generate-toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,22 @@ import {
isGenerationOptionValueValid,
missingGenerationOptions,
reconcileGenerationOptions,
type GenerationAssetType,
type GenerationModelDefinition,
type GenerationOptionDefinition
} from "@core/generation/model-catalogue";
import { MERGE_FIELD_TEST_PATTERN } from "@core/merge/merge-field-service";
import { canCarryPrompt } from "@core/shared/ai-asset-utils";
import { canCarryPrompt, GENERATION_TYPE, promptProperty } from "@core/shared/ai-asset-utils";
import { injectShotstackStyles } from "@styles/inject";

import { BaseToolbar, TOOLBAR_ICONS } from "./base-toolbar";

const PROMPT_DEBOUNCE_MS = 300;
const GENERATION_TYPE: Readonly<Record<string, GenerationAssetType>> = {
image: "image",
video: "video",
audio: "audio",
"text-to-image": "image",
"image-to-video": "video",
"text-to-speech": "audio"
};

const OPTION_INPUT_TYPE: Readonly<Record<GenerationOptionDefinition["type"], string>> = {
boolean: "checkbox",
integer: "number",
string: "text"
};

const promptProperty = (asset: { type: string }): "prompt" | "text" => (asset.type === "text-to-speech" ? "text" : "prompt");
const record = (value: unknown): Record<string, unknown> =>
typeof value === "object" && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : {};

Expand Down
Loading