import type { IntentInputPolicy } from '../intentInputPolicy.ts' import type { IntentDynamicStepExecutionDefinition, IntentRunnerKind, PreparedIntentInputs, } from '../intentRuntime.ts' import { imageDescribeSemanticIntentDescriptor } from './imageDescribe.ts' import { imageGenerateSemanticIntentDescriptor } from './imageGenerate.ts' import { markdownDocxSemanticIntentDescriptor, markdownPdfSemanticIntentDescriptor, } from './markdownPdf.ts' import { speechTranscribeSemanticIntentDescriptor } from './speechTranscribe.ts' export interface SemanticIntentPresentation { description: string details: string examples: Array<[string, string]> } export interface SemanticIntentDescriptor { createStep: ( rawValues: Record, context: { hasInputs: boolean }, ) => Record defaultOutputPath: string execution: IntentDynamicStepExecutionDefinition inputPolicy: IntentInputPolicy outputDescription: string prepareInputs?: ( preparedInputs: PreparedIntentInputs, rawValues: Record, ) => Promise presentation: SemanticIntentPresentation runnerKind: IntentRunnerKind } const semanticIntentDescriptors: Record = { 'image-describe': imageDescribeSemanticIntentDescriptor, 'image-generate': imageGenerateSemanticIntentDescriptor, 'markdown-pdf': { ...markdownPdfSemanticIntentDescriptor, }, 'markdown-docx': { ...markdownDocxSemanticIntentDescriptor, }, 'speech-transcribe': speechTranscribeSemanticIntentDescriptor, } export function getSemanticIntentDescriptor(name: string): SemanticIntentDescriptor { if (!(name in semanticIntentDescriptors)) { throw new Error(`Semantic intent descriptor does not exist for "${name}"`) } return semanticIntentDescriptors[name] }