UNPKG

@langchain/langgraph-sdk

Version:

Client library for interacting with the LangGraph API

138 lines (137 loc) • 5.07 kB
import { CancelAction, DefaultValues, Run, RunSelectField, RunStatus, ThreadState } from "../../schema.js"; import { IdleReconnectMode } from "../../utils/stream.js"; import { StreamMode, TypedAsyncGenerator } from "../../types.stream.js"; import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent } from "../../types.js"; import { BaseClient } from "../base.js"; //#region src/client/runs/index.d.ts declare class RunsClient<TStateType = DefaultValues, TUpdateType = TStateType, TCustomEventType = unknown> extends BaseClient { stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: null, assistantId: string, payload?: Omit<RunsStreamPayload<TStreamMode, TSubgraphs>, "multitaskStrategy" | "onCompletion">): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>; stream<TStreamMode extends StreamMode | StreamMode[] = StreamMode, TSubgraphs extends boolean = false>(threadId: string, assistantId: string, payload?: RunsStreamPayload<TStreamMode, TSubgraphs>): TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>; /** * Create a run. * * @param threadId The ID of the thread. * @param assistantId Assistant ID to use for this run. * @param payload Payload for creating a run. * @returns The created run. */ create(threadId: string | null, assistantId: string, payload?: RunsCreatePayload): Promise<Run>; /** * Create a batch of stateless background runs. * * @param payloads An array of payloads for creating runs. * @returns An array of created runs. */ createBatch(payloads: (Omit<RunsCreatePayload, "signal"> & { assistantId: string; })[], options?: { signal?: AbortSignal; }): Promise<Run[]>; wait(threadId: null, assistantId: string, payload?: Omit<RunsWaitPayload, "multitaskStrategy" | "onCompletion">): Promise<ThreadState["values"]>; wait(threadId: string, assistantId: string, payload?: RunsWaitPayload): Promise<ThreadState["values"]>; /** * List all runs for a thread. * * @param threadId The ID of the thread. * @param options Filtering and pagination options. * @returns List of runs. */ list(threadId: string, options?: { limit?: number; offset?: number; status?: RunStatus; select?: RunSelectField[]; signal?: AbortSignal; }): Promise<Run[]>; /** * Get a run by ID. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns The run. */ get(threadId: string, runId: string, options?: { signal?: AbortSignal; }): Promise<Run>; /** * Cancel a run. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @param wait Whether to block when canceling * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`. * @returns */ cancel(threadId: string, runId: string, wait?: boolean, action?: CancelAction, options?: { signal?: AbortSignal; }): Promise<void>; /** * Cancel one or more runs. * * @param options Options for cancelling runs. * @returns */ cancelMany(options: { threadId?: string; runIds?: string[]; status?: "pending" | "running" | "all"; action?: CancelAction; signal?: AbortSignal; }): Promise<void>; /** * Block until a run is done. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns */ join(threadId: string, runId: string, options?: { cancelOnDisconnect?: boolean; signal?: AbortSignal; }): Promise<TStateType>; /** * Stream output from a run in real-time, until the run is done. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @param options Additional options for controlling the stream behavior. * @returns An async generator yielding stream parts. */ joinStream(threadId: string | undefined | null, runId: string, options?: { signal?: AbortSignal; cancelOnDisconnect?: boolean; lastEventId?: string; streamMode?: StreamMode | StreamMode[]; /** * Idle-reconnect policy. * * Guards against half-open sockets that hang with no * error or close; on idle the read re-joins with the last seen * `Last-Event-ID`. * * - `"auto"` (default): arms only once the * server's keep-alive heartbeats are observed and sizes the window * from their cadence; * - a `number`: a fixed idle window in ms; * - `0`: disables it. */ streamIdleReconnect?: IdleReconnectMode; } | AbortSignal): AsyncGenerator<{ id?: string; event: StreamEvent; data: any; }>; /** * Delete a run. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns */ delete(threadId: string, runId: string, options?: { signal?: AbortSignal; }): Promise<void>; } //#endregion export { RunsClient }; //# sourceMappingURL=index.d.ts.map