providerplaneai
    Preparing search index...

    Class GenericJob<TInput, TOutput>

    GenericJob manages the lifecycle, execution, and state of an AI job, supporting streaming and non-streaming modes. Handles input, output, error, status, artifacts, and raw response management, with hooks for orchestration.

    Type Parameters

    • TInput

      The input type for the job.

    • TOutput

      The output type for the job.

    Implements

    Index

    Constructors

    • Constructs a new GenericJob instance.

      Type Parameters

      • TInput

        The input type for the job.

      • TOutput

        The output type for the job.

      Parameters

      • input: TInput

        The job input.

      • streamingEnabled: boolean = false

        Whether streaming is enabled for this job.

      • executor: (
            input: TInput,
            ctx: MultiModalExecutionContext,
            signal?: AbortSignal,
            onChunk?: (
                chunk: JobChunk<TOutput>,
                internalChunk?: AIResponseChunk<TOutput>,
            ) => void,
        ) => Promise<AIResponse<TOutput>>

        The function to execute the job.

      • Optionalhooks: JobLifecycleHooks<TOutput>

        Optional lifecycle hooks.

      • OptionalmaxStoredResponseChunks: number

        Max number of response chunks to store.

      • OptionalexecutionMetadata: {
            capability?: CapabilityKeyType;
            maxRawBytesPerJob?: number;
            providerChain?: ProviderRef[];
            storeRawResponses?: boolean;
            stripBinaryPayloadsInSnapshotsAndTimeline?: boolean;
        }

        Optional metadata for execution (capability, provider chain, etc).

      Returns GenericJob<TInput, TOutput>

    Properties

    input: TInput

    The job input.

    onChunk?: (chunk: JobChunk<TOutput>) => void

    Optional streaming callback

    onStatusChange?: (status: JobStatus) => void

    Called whenever status changes

    Accessors

    • get id(): `${string}-${string}-${string}-${string}-${string}`

      Returns `${string}-${string}-${string}-${string}-${string}`

    Methods

    • Run the job. NOTE: Consumers should typically call JobManager.runJob() instead of invoking this directly, to ensure proper concurrency management, hooks, and persistence.

      Parameters

      • ctx: MultiModalExecutionContext

        MultiModalExecutionContext

      • Optionalsignal: AbortSignal

        Optional abort signal

      • OptionalonChunk: (chunk: JobChunk<TOutput>) => void

        Optional streaming callback (overrides existing onChunk)

      Returns Promise<void>