Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update model options and refactor default model handling

konstantin-pauluse5b8971aac28
diff --git a/apps/web/src/components/genai/config.ts b/apps/web/src/components/genai/config.ts
index 3f239004..6a05b311 100644
--- a/apps/web/src/components/genai/config.ts
+++ b/apps/web/src/components/genai/config.ts
@@ -283,24 +283,16 @@ const seconds = (from: number, to: number) => Array.from({ length: to - from + 1
const image = { mode: "IMAGE", aspectRatios: ALL_ASPECT_RATIOS, counts: [1, 2, 3, 4] } satisfies Partial<ModelOption>;
const video = { mode: "VIDEO" } satisfies Partial<ModelOption>;
+/** Most relevant first, per mode: the order the model menu lists them in. */
export const MODEL_OPTIONS: ModelOption[] = [
{
...image,
- id: "flux-2-klein",
- name: "FLUX.2 Klein",
- icon: "large-bfl",
- description: "Low budget, high quality, fast.",
- references: 4,
- resolutions: ["1K"],
- },
- {
- ...image,
- id: "flux-2-pro",
- name: "FLUX.2 Pro",
- icon: "large-bfl",
- description: "Frontier quality, consistent references.",
- references: 8,
- resolutions: ["1K"],
+ id: "nano-banana-pro",
+ name: "Nano Banana Pro",
+ icon: "large-google",
+ description: "Pro control, readable text, ultra consistent.",
+ references: 14,
+ resolutions: ["1K", "2K", "4K"],
},
{
...image,
@@ -320,15 +312,6 @@ export const MODEL_OPTIONS: ModelOption[] = [
references: 14,
resolutions: ["1K", "2K", "4K"],
},
- {
- ...image,
- id: "nano-banana-pro",
- name: "Nano Banana Pro",
- icon: "large-google",
- description: "Pro control, readable text, ultra consistent.",
- references: 14,
- resolutions: ["1K", "2K", "4K"],
- },
{
...image,
id: "seedream-5.0-pro",
@@ -338,6 +321,15 @@ export const MODEL_OPTIONS: ModelOption[] = [
references: 14,
resolutions: ["1K", "2K"],
},
+ {
+ ...image,
+ id: "flux-2-pro",
+ name: "FLUX.2 Pro",
+ icon: "large-bfl",
+ description: "Frontier quality, consistent references.",
+ references: 8,
+ resolutions: ["1K"],
+ },
{
...image,
id: "grok-imagine-image-2.0",
@@ -347,6 +339,15 @@ export const MODEL_OPTIONS: ModelOption[] = [
references: 3,
resolutions: ["1K", "2K"],
},
+ {
+ ...image,
+ id: "flux-2-klein",
+ name: "FLUX.2 Klein",
+ icon: "large-bfl",
+ description: "Low budget, high quality, fast.",
+ references: 4,
+ resolutions: ["1K"],
+ },
{
...image,
id: "krea-2-large",
@@ -357,6 +358,18 @@ export const MODEL_OPTIONS: ModelOption[] = [
aspectRatios: ["16:9", "9:16", "1:1", "4:3"],
resolutions: ["1K"],
},
+ {
+ ...video,
+ id: "veo-3.1",
+ name: "Veo 3.1",
+ icon: "large-google",
+ description: "Realistic physics, complex scenes.",
+ frames: ["start", "end"],
+ durations: [4, 6, 8],
+ aspectRatios: ["16:9", "9:16"],
+ resolutions: ["720p", "1080p"],
+ resolutionDurations: { "1080p": [8] },
+ },
{
...video,
id: "kling-3-pro",
@@ -368,16 +381,6 @@ export const MODEL_OPTIONS: ModelOption[] = [
aspectRatios: ["16:9", "9:16", "1:1"],
resolutions: ["720p"],
},
- {
- ...video,
- id: "kling-o3-pro",
- name: "Kling 3.0 Omni",
- icon: "large-kling",
- description: "Multi-modal reasoning, strong scenes.",
- frames: ["start"],
- durations: seconds(3, 15),
- resolutions: ["1080p"],
- },
{
...video,
id: "seedance-2.5",
@@ -389,18 +392,6 @@ export const MODEL_OPTIONS: ModelOption[] = [
aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
resolutions: ["480p", "720p"],
},
- {
- ...video,
- id: "veo-3.1",
- name: "Veo 3.1",
- icon: "large-google",
- description: "Realistic physics, complex scenes.",
- frames: ["start", "end"],
- durations: [4, 6, 8],
- aspectRatios: ["16:9", "9:16"],
- resolutions: ["720p", "1080p"],
- resolutionDurations: { "1080p": [8] },
- },
{
...video,
id: "veo-3.1-fast",
@@ -415,14 +406,13 @@ export const MODEL_OPTIONS: ModelOption[] = [
},
{
...video,
- id: "flux-3-video",
- name: "FLUX.3 Video",
- icon: "large-bfl",
- description: "Sharp detail with native audio.",
- frames: ["start", "end"],
- durations: seconds(5, 20),
- aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
- resolutions: ["720p", "1080p"],
+ id: "kling-o3-pro",
+ name: "Kling 3.0 Omni",
+ icon: "large-kling",
+ description: "Multi-modal reasoning, strong scenes.",
+ frames: ["start"],
+ durations: seconds(3, 15),
+ resolutions: ["1080p"],
},
{
...video,
@@ -446,6 +436,17 @@ export const MODEL_OPTIONS: ModelOption[] = [
aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
resolutions: ["2K"],
},
+ {
+ ...video,
+ id: "flux-3-video",
+ name: "FLUX.3 Video",
+ icon: "large-bfl",
+ description: "Sharp detail with native audio.",
+ frames: ["start", "end"],
+ durations: seconds(5, 20),
+ aspectRatios: ["16:9", "9:16", "1:1", "4:3", "3:4"],
+ resolutions: ["720p", "1080p"],
+ },
{
...video,
id: "grok-imagine-video-1.5",
@@ -481,9 +482,20 @@ export const MODEL_OPTIONS: ModelOption[] = [
},
];
-/** The models the prompt box offers in `mode`, the first one by default. */
+/** The model each mode starts with: the cheap one, not the most relevant. */
+const DEFAULT_MODELS: Record<PromptMode, ModelId> = {
+ IMAGE: "flux-2-klein",
+ VIDEO: "kling-3-pro",
+ VOICE: "elevenlabs-v3",
+ AUDIO: "elevenlabs-music",
+};
+
+/** The models the prompt box offers in `mode`. */
export const modelOptions = (mode: PromptMode) => MODEL_OPTIONS.filter((option) => option.mode === mode);
+/** The model the prompt box starts `mode` with. */
+export const defaultModelOption = (mode: PromptMode) => modelOption(DEFAULT_MODELS[mode])!;
+
/** The prompt box's option for `id`; undefined for a model it doesn't make requests with (tools, text). */
export const modelOption = (id: ModelId) => MODEL_OPTIONS.find((option) => option.id === id);
diff --git a/apps/web/src/components/genai/requests.ts b/apps/web/src/components/genai/requests.ts
index 44a0beb3..4f219cf1 100644
--- a/apps/web/src/components/genai/requests.ts
+++ b/apps/web/src/components/genai/requests.ts
@@ -10,7 +10,7 @@
import { uploadAsset } from "@/engine/generate";
import { AUDIO_SIZE } from "@/engine/insert-asset";
-import { ASPECT_RATIO_DIMENSIONS, DEFAULT_RESOLUTION, MODEL_MODES, durationsAt, modelOption, modelOptions } from "./config";
+import { ASPECT_RATIO_DIMENSIONS, DEFAULT_RESOLUTION, MODEL_MODES, defaultModelOption, durationsAt, modelOption } from "./config";
import type { AssetLibrary } from "@diffusionstudio/assets";
import type { AssetRef, GenerateRequest, GenerateRequestInput, ModelId, Resolution } from "@diffusionstudio/api-contract";
@@ -72,7 +72,7 @@ function pick<T>(value: T | undefined, allowed: readonly T[] | undefined, fallba
* The resolution is fitted first: it may narrow the durations (Veo's 1080p).
*/
export function fitToModel(config: GenerationConfig): GenerationConfig {
- const option = modelOption(config.model) ?? modelOptions(config.mode)[0]!;
+ const option = modelOption(config.model) ?? defaultModelOption(config.mode);
const frame = (frame: "start" | "end", id: string | undefined) => (option.frames?.includes(frame) ? id : undefined);
const resolution = pick(config.resolution, option.resolutions, DEFAULT_RESOLUTION[option.mode]);
return {
@@ -92,7 +92,7 @@ export function fitToModel(config: GenerationConfig): GenerationConfig {
/** The prompt box in `mode`, set up for the mode's first model. */
export function createDefaultConfig(mode: PromptMode, prompt = ""): GenerationConfig {
- return fitToModel({ mode, model: modelOptions(mode)[0]!.id, prompt });
+ return fitToModel({ mode, model: defaultModelOption(mode).id, prompt });
}
/** The request `config` makes, its library inputs uploaded. Settings the config leaves unset are left out. */