8.6 KiB
@langchain/langgraph-sdk / RunsClient
Class: RunsClient<TStateType, TUpdateType, TCustomEventType>
Defined in: client.ts:912
Extends
BaseClient
Type Parameters
• TStateType = DefaultValues
• TUpdateType = TStateType
• TCustomEventType = unknown
Constructors
new RunsClient()
new RunsClient<
TStateType,TUpdateType,TCustomEventType>(config?):RunsClient<TStateType,TUpdateType,TCustomEventType>
Defined in: client.ts:183
Parameters
config?
Returns
RunsClient<TStateType, TUpdateType, TCustomEventType>
Inherited from
BaseClient.constructor
Methods
cancel()
cancel(
threadId,runId,wait,action):Promise<void>
Defined in: client.ts:1227
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()
create(
threadId,assistantId,payload?):Promise<Run>
Defined in: client.ts:1026
Create a run.
Parameters
threadId
string
The ID of the thread.
assistantId
string
Assistant ID to use for this run.
payload?
RunsCreatePayload
Payload for creating a run.
Returns
Promise<Run>
The created run.
createBatch()
createBatch(
payloads):Promise<Run[]>
Defined in: client.ts:1076
Create a batch of stateless background runs.
Parameters
payloads
RunsCreatePayload & object[]
An array of payloads for creating runs.
Returns
Promise<Run[]>
An array of created runs.
delete()
delete(
threadId,runId):Promise<void>
Defined in: client.ts:1329
Delete a run.
Parameters
threadId
string
The ID of the thread.
runId
string
The ID of the run.
Returns
Promise<void>
get()
get(
threadId,runId):Promise<Run>
Defined in: client.ts:1214
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.
join()
join(
threadId,runId,options?):Promise<void>
Defined in: client.ts:1249
Block until a run is done.
Parameters
threadId
string
The ID of the thread.
runId
string
The ID of the run.
options?
signal?
AbortSignal
Returns
Promise<void>
joinStream()
joinStream(
threadId,runId,options?):AsyncGenerator<{data:any;event:StreamEvent;id:string; }>
Defined in: client.ts:1274
Stream output from a run in real-time, until the run is done.
Parameters
threadId
The ID of the thread. Can be set to null | undefined for stateless runs.
undefined | null | string
runId
string
The ID of the run.
options?
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.
AbortSignal | { cancelOnDisconnect: boolean; lastEventId: string; signal: AbortSignal; streamMode: StreamMode | StreamMode[]; }
Returns
AsyncGenerator<{ data: any; event: StreamEvent; id: string; }>
An async generator yielding stream parts.
list()
list(
threadId,options?):Promise<Run[]>
Defined in: client.ts:1177
List all runs for a thread.
Parameters
threadId
string
The ID of the thread.
options?
Filtering and pagination options.
limit?
number
Maximum number of runs to return. Defaults to 10
offset?
number
Offset to start from. Defaults to 0.
status?
RunStatus
Status of the run to filter by.
Returns
Promise<Run[]>
List of runs.
stream()
Create a run and stream the results.
Param
The ID of the thread.
Param
Assistant ID to use for this run.
Param
Payload for creating a run.
Call Signature
stream<
TStreamMode,TSubgraphs>(threadId,assistantId,payload?):TypedAsyncGenerator<TStreamMode,TSubgraphs,TStateType,TUpdateType,TCustomEventType>
Defined in: client.ts:917
Type Parameters
• TStreamMode extends StreamMode | StreamMode[] = StreamMode
• TSubgraphs extends boolean = false
Parameters
threadId
null
assistantId
string
payload?
Omit<RunsStreamPayload<TStreamMode, TSubgraphs>, "multitaskStrategy" | "onCompletion">
Returns
TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>
Call Signature
stream<
TStreamMode,TSubgraphs>(threadId,assistantId,payload?):TypedAsyncGenerator<TStreamMode,TSubgraphs,TStateType,TUpdateType,TCustomEventType>
Defined in: client.ts:935
Type Parameters
• TStreamMode extends StreamMode | StreamMode[] = StreamMode
• TSubgraphs extends boolean = false
Parameters
threadId
string
assistantId
string
payload?
RunsStreamPayload<TStreamMode, TSubgraphs>
Returns
TypedAsyncGenerator<TStreamMode, TSubgraphs, TStateType, TUpdateType, TCustomEventType>
wait()
Create a run and wait for it to complete.
Param
The ID of the thread.
Param
Assistant ID to use for this run.
Param
Payload for creating a run.
Call Signature
wait(
threadId,assistantId,payload?):Promise<DefaultValues>
Defined in: client.ts:1093
Parameters
threadId
null
assistantId
string
payload?
Omit<RunsWaitPayload, "multitaskStrategy" | "onCompletion">
Returns
Promise<DefaultValues>
Call Signature
wait(
threadId,assistantId,payload?):Promise<DefaultValues>
Defined in: client.ts:1099
Parameters
threadId
string
assistantId
string
payload?
RunsWaitPayload
Returns
Promise<DefaultValues>