UNPKG

@smythos/sdk

Version:
82 lines (68 loc) 2.55 kB
//!!! DO NOT EDIT THIS FILE, IT IS AUTO-GENERATED !!!// import { Agent } from '../../Agent/Agent.class'; import { createSafeAccessor } from '../utils'; import { ComponentWrapper } from '../ComponentWrapper.class'; import { InputSettings, ComponentInput } from '../../types/SDKTypes'; export interface TImageGeneratorSettings { name?: string; model: string; /** Prompt */ prompt?: string; sizeDalle2?: '256x256' | '512x512' | '1024x1024'; sizeDalle3?: '1024x1024' | '1792x1024' | '1024x1792'; quality?: 'standard' | 'hd' | 'auto' | 'high' | 'medium' | 'low'; style?: 'vivid' | 'natural'; isRawInputPrompt?: boolean; /** Negative Prompt */ negativePrompt?: string; width?: number; height?: number; outputFormat?: 'PNG' | 'JPEG' | 'WEBP' | 'auto' | 'jpeg' | 'png' | 'webp'; /** Size */ size?: string; /** Aspect Ratio */ aspectRatio?: '1:1' | '3:4' | '4:3' | '9:16' | '16:9'; /** Person Generation */ personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all'; } export type TImageGeneratorInputs = { [key: string]: InputSettings; }; export type TImageGeneratorOutputs = { [key: string]: any; }; export function ImageGenerator(settings?: TImageGeneratorSettings, agent?: Agent) { const { name, ...settingsWithoutName } = settings || {}; const dataObject: any = { name: settings?.name || 'ImageGenerator', settings: { ...settingsWithoutName } }; const component = new ComponentWrapper(dataObject, agent); if (agent) { (agent.structure.components as ComponentWrapper[]).push(component); } const _out: TImageGeneratorOutputs = createSafeAccessor({ // No outputs defined }, component, ''); const _in: { [key: string]: ComponentInput } = { // No inputs defined }; dataObject.outputs = _out; dataObject.inputs = _in; component.inputs(_in); const wrapper = { /** Component outputs - access via .out.OutputName */ out: _out, /** * Create or Connect the component inputs * if the input does not exist, it will be created * @examples * - component.in({ Input: source.out.data }) * - component.in({ Input: { type: 'string', source:source.out.data } }) */ in: component.inputs.bind(component) as (inputs: TImageGeneratorInputs) => void, }; return wrapper; }