mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-17 23:27:56 +02:00
feat(sdk-js): add bulkUpdateState method
This commit is contained in:
@@ -638,6 +638,33 @@ export class ThreadsClient<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new thread from a batch states.
|
||||
*/
|
||||
async bulkUpdateState(
|
||||
supersteps: Array<{ updates: Array<{ values: unknown; asNode: string }> }>,
|
||||
options: {
|
||||
threadId?: string;
|
||||
metadata?: Metadata;
|
||||
ifExists?: OnConflictBehavior;
|
||||
},
|
||||
): Promise<Thread<TStateType>> {
|
||||
return this.fetch<Thread<TStateType>>("/threads/state/batch", {
|
||||
method: "POST",
|
||||
json: {
|
||||
supersteps: supersteps.map((s) => ({
|
||||
updates: s.updates.map((u) => ({
|
||||
values: u.values,
|
||||
as_node: u.asNode,
|
||||
})),
|
||||
})),
|
||||
thread_id: options.threadId,
|
||||
metadata: options.metadata,
|
||||
if_exists: options.ifExists,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch the metadata of a thread.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user