UNPKG

@promptbook/azure-openai

Version:

Promptbook: Run AI apps in plain human language across multiple models and platforms

71 lines (70 loc) 3.3 kB
import type { ReadonlyDeep, WritableDeep } from 'type-fest'; import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson'; import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson'; import type { Parameters } from '../../types/typeAliases'; import type { string_parameter_name } from '../../types/typeAliases'; import type { TODO_string } from '../../utils/organization/TODO_string'; import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson'; import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions'; /** * Options for executing attempts of a pipeline task, including configuration for jokers, priority, * maximum attempts, prepared content, parameters, the task itself, the prepared pipeline, execution report, * and pipeline identification. Used internally by the pipeline executor. * * @private internal type of `executeAttempts` */ export type ExecuteAttemptsOptions = Required<Omit<CreatePipelineExecutorOptions, 'pipeline'>> & { /** * Names of parameters that act as jokers, which can be used to bypass normal execution if their value meets requirements. */ readonly jokerParameterNames: Readonly<ReadonlyArray<string_parameter_name>>; /** * Priority of the current execution attempt, used to influence UI or execution order. */ readonly priority: number; /** * Maximum number of attempts allowed for this task, including retries and joker attempts. * Note: [💂] There are two distinct variables * 1) `maxExecutionAttempts` - attempts for LLM model * 2) `maxAttempts` - attempts for any task (LLM, SCRIPT, DIALOG, etc.) */ readonly maxAttempts: number; /** * The content prepared for execution, with parameters already substituted. */ readonly preparedContent: TODO_string; /** * The parameters provided for this execution attempt. */ readonly parameters: Readonly<Parameters>; /** * The task being executed, as a deeply immutable TaskJson object. * Note: Naming should be unified between `task` and `currentTask`. */ readonly task: ReadonlyDeep<TaskJson>; /** * The pipeline structure prepared for execution, as a deeply immutable PipelineJson object. */ readonly preparedPipeline: ReadonlyDeep<PipelineJson>; /** * The execution report object, which is updated during execution. */ readonly $executionReport: WritableDeep<ExecutionReportJson>; /** * String identifier for the pipeline, used for logging and error reporting. */ readonly pipelineIdentification: string; }; /** * Executes a pipeline task with multiple attempts, including joker and retry logic. Handles different task types * (prompt, script, dialog, etc.), applies postprocessing, checks expectations, and updates the execution report. * Throws errors if execution fails after all attempts. * * @param options - The options for execution, including task, parameters, pipeline, and configuration. * @returns The result string of the executed task. * @private internal utility of `createPipelineExecutor` */ export declare function executeAttempts(options: ExecuteAttemptsOptions): Promise<TODO_string>; /** * TODO: Break into smaller functions */