UNPKG

@imgly/plugin-ai-generation-web

Version:

AI generation plugin for the CE.SDK editor

57 lines (56 loc) 1.93 kB
import { QuickActionDefinition } from '../core/ActionRegistry'; import { Result } from './createGenerateFunction'; import { ProviderInitializationResult } from '../providers/initializeProvider'; import { Middleware } from '../middleware/middleware'; import { Output, OutputKind } from '../core/provider'; import CreativeEditorSDK from '@cesdk/cesdk-js'; type GenerationOptions<Q extends Record<string, any>, K extends OutputKind, I, O extends Output> = { /** * The blocks that this quick action is running on. */ blockIds: number[]; /** * The initlaized provider that is used to generate the output. */ providerInitializationResult?: ProviderInitializationResult<K, I, O>; /** * The quick action definition that is used to generate input for the provider */ quickAction: QuickActionDefinition<Q>; /** * Shall the generation be confirmed before applying the result? Or directly applied? */ confirmation?: boolean; /** * Should the blocks be locked to edit mode while the generation is running? */ lock?: boolean; /** * Additional middlewares added to the generation process. */ middlewares?: Middleware<I, O>[]; /** * Print debug information to the console. */ debug?: boolean; /** * Enable dry run mode for testing. */ dryRun?: boolean; /** * Signal to check if process was aborted */ abortSignal?: AbortSignal; /** * Close the quick action menu */ close: () => void; cesdk: CreativeEditorSDK; }; /** * Handler for generating output from a quick action. */ declare function handleGenerateFromQuickAction<Q extends Record<string, any>, K extends OutputKind, I, O extends Output>(options: GenerationOptions<Q, K, I, O>): (input: Q, generateOptions?: { blockIds?: number[]; }) => Promise<Result<O>>; export default handleGenerateFromQuickAction;