langchain.js
    Preparing search index...

    Class RunsClient<TStateType, TUpdateType, TCustomEventType>

    Type Parameters

    Hierarchy

    • BaseClient
      • RunsClient
    Index

    Constructors

    Properties

    apiUrl: string
    asyncCaller: AsyncCaller
    defaultHeaders: Record<string, HeaderValue>
    onRequest?: RequestHook
    timeoutMs: undefined | number

    Methods

    • Cancel a run.

      Parameters

      • threadId: string

        The ID of the thread.

      • runId: string

        The ID of the run.

      • wait: boolean = false

        Whether to block when canceling

      • action: CancelAction = "interrupt"

        Action to take when cancelling the run. Possible values are interrupt or rollback. Default is interrupt.

      Returns Promise<void>

    • Create a run.

      Parameters

      • threadId: string

        The ID of the thread.

      • assistantId: string

        Assistant ID to use for this run.

      • Optionalpayload: RunsCreatePayload

        Payload for creating a run.

      Returns Promise<Run>

      The created run.

    • Create a batch of stateless background runs.

      Parameters

      • payloads: (RunsCreatePayload & { assistantId: string })[]

        An array of payloads for creating runs.

      Returns Promise<Run[]>

      An array of created runs.

    • Delete a run.

      Parameters

      • threadId: string

        The ID of the thread.

      • runId: string

        The ID of the run.

      Returns Promise<void>

    • Type Parameters

      • T

      Parameters

      • path: string
      • options: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            signal?: AbortSignal;
            timeoutMs?: null | number;
            withResponse: true;
        }

      Returns Promise<[T, Response]>

    • Type Parameters

      • T

      Parameters

      • path: string
      • Optionaloptions: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            signal?: AbortSignal;
            timeoutMs?: null | number;
            withResponse?: false;
        }

      Returns Promise<T>

    • Get a run by ID.

      Parameters

      • threadId: string

        The ID of the thread.

      • runId: string

        The ID of the run.

      Returns Promise<Run>

      The run.

    • Block until a run is done.

      Parameters

      • threadId: string

        The ID of the thread.

      • runId: string

        The ID of the run.

      • Optionaloptions: { signal?: AbortSignal }

      Returns Promise<TStateType>

    • Stream output from a run in real-time, until the run is done.

      Parameters

      • threadId: undefined | null | string

        The ID of the thread. Can be set to null | undefined for stateless runs.

      • runId: string

        The ID of the run.

      • Optionaloptions:
            | AbortSignal
            | {
                cancelOnDisconnect?: boolean;
                lastEventId?: string;
                signal?: AbortSignal;
                streamMode?: StreamMode
                | StreamMode[];
            }

        Additional options for controlling the stream behavior:

        • signal: An AbortSignal that can be used to cancel the stream request
        • lastEventId: The ID of the last event received. Can be used to reconnect to a stream without losing events.
        • cancelOnDisconnect: When true, automatically cancels the run if the client disconnects from the stream
        • streamMode: Controls what types of events to receive from the stream (can be a single mode or array of modes) Must be a subset of the stream modes passed when creating the run. Background runs default to having the union of all stream modes enabled.

      Returns AsyncGenerator<{ data: any; event: StreamEvent; id?: string }>

      An async generator yielding stream parts.

    • List all runs for a thread.

      Parameters

      • threadId: string

        The ID of the thread.

      • Optionaloptions: {
            limit?: number;
            offset?: number;
            select?: RunSelectField[];
            status?: RunStatus;
        }

        Filtering and pagination options.

        • Optionallimit?: number

          Maximum number of runs to return. Defaults to 10

        • Optionaloffset?: number

          Offset to start from. Defaults to 0.

        • Optionalselect?: RunSelectField[]
        • Optionalstatus?: RunStatus

          Status of the run to filter by.

      Returns Promise<Run[]>

      List of runs.

    • Parameters

      • path: string
      • Optionaloptions: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            timeoutMs?: null | number;
            withResponse?: boolean;
        }

      Returns [url: URL, init: RequestInit]

    • Parameters

      • threadId: null
      • assistantId: string
      • Optionalpayload: Omit<RunsWaitPayload, "multitaskStrategy" | "onCompletion">

      Returns Promise<DefaultValues>

    • Parameters

      • threadId: string
      • assistantId: string
      • Optionalpayload: RunsWaitPayload

      Returns Promise<DefaultValues>