feat(sdk-js): add bulkUpdateState method

This commit is contained in:
Tat Dat Duong
2025-03-17 17:22:03 +01:00
parent def69c59d2
commit 1a728a93c6
+27
View File
@@ -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.
*