Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { get } from 'es-toolkit/compat';
import type { FieldInputInstance, FieldInputTemplate, FieldValue, StatefulFieldType } from 'features/nodes/types/field';
const FIELD_VALUE_FALLBACK_MAP: Record<StatefulFieldType['name'], FieldValue> = {
EnumField: '',
BoardField: undefined,
BooleanField: false,
ColorField: { r: 0, g: 0, b: 0, a: 1 },
FloatField: 0,
ImageField: undefined,
VideoField: undefined,
IntegerField: 0,
ModelIdentifierField: undefined,
LoRAField: [],
SchedulerField: 'dpmpp_3m_k',
SavedWorkflowField: '',
StringField: '',
StylePresetField: undefined,
SystemPromptField: undefined,
FloatGeneratorField: undefined,
IntegerGeneratorField: undefined,
StringGeneratorField: undefined,
ImageGeneratorField: undefined,
LoRAMetadataField: undefined,
ControlNetMetadataField: undefined,
IPAdapterMetadataField: undefined,
T2IAdapterMetadataField: undefined,
MetadataExtraField: undefined,
};
export const buildFieldInputInstance = (id: string, template: FieldInputTemplate): FieldInputInstance => {
const fieldInstance: FieldInputInstance = {
name: template.name,
label: '',
description: '',
value: template.default ?? get(FIELD_VALUE_FALLBACK_MAP, template.type.name),
};
return fieldInstance;
};