mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-31 04:09:49 +02:00
feat(sdk-js): add bulkUpdateState method (#3878)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@langchain/langgraph-sdk",
|
||||
"version": "0.0.57",
|
||||
"version": "0.0.59",
|
||||
"description": "Client library for interacting with the LangGraph API",
|
||||
"type": "module",
|
||||
"packageManager": "yarn@1.22.19",
|
||||
|
||||
@@ -30,6 +30,7 @@ import type {
|
||||
StreamEvent,
|
||||
CronsCreatePayload,
|
||||
OnConflictBehavior,
|
||||
Command,
|
||||
} from "./types.js";
|
||||
import { mergeSignals } from "./utils/signals.js";
|
||||
import { getEnvironmentVariable } from "./utils/env.js";
|
||||
@@ -638,6 +639,40 @@ export class ThreadsClient<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new thread from a batch states.
|
||||
*/
|
||||
async bulkUpdateState(
|
||||
supersteps: Array<{
|
||||
updates: Array<{ values: unknown; command?: Command; asNode: string }>;
|
||||
}>,
|
||||
options?: {
|
||||
graphId?: string;
|
||||
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,
|
||||
command: u.command,
|
||||
as_node: u.asNode,
|
||||
})),
|
||||
})),
|
||||
thread_id: options?.threadId,
|
||||
metadata: {
|
||||
...options?.metadata,
|
||||
graph_id: options?.graphId,
|
||||
},
|
||||
if_exists: options?.ifExists,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch the metadata of a thread.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user