@langchain/langgraph 0.2.46 → 0.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/func/index.cjs +0 -15
- package/dist/func/index.d.ts +0 -40
- package/dist/func/index.js +0 -15
- package/dist/prebuilt/index.cjs +2 -1
- package/dist/prebuilt/index.d.ts +1 -1
- package/dist/prebuilt/index.js +1 -1
- package/dist/prebuilt/react_agent_executor.cjs +4 -1
- package/dist/prebuilt/react_agent_executor.d.ts +1 -1
- package/dist/prebuilt/react_agent_executor.js +4 -1
- package/dist/pregel/index.cjs +314 -33
- package/dist/pregel/index.d.ts +374 -61
- package/dist/pregel/index.js +314 -33
- package/dist/pregel/io.cjs +49 -24
- package/dist/pregel/io.d.ts +8 -1
- package/dist/pregel/io.js +49 -24
- package/dist/pregel/loop.cjs +11 -0
- package/dist/pregel/loop.d.ts +1 -0
- package/dist/pregel/loop.js +12 -1
- package/dist/pregel/runner.cjs +24 -22
- package/dist/pregel/runner.d.ts +0 -3
- package/dist/pregel/runner.js +25 -23
- package/dist/pregel/types.d.ts +154 -30
- package/dist/web.d.ts +1 -1
- package/package.json +4 -4
package/dist/func/index.cjs
CHANGED
|
@@ -12,11 +12,6 @@ const utils_js_1 = require("../utils.cjs");
|
|
|
12
12
|
/**
|
|
13
13
|
* Define a LangGraph task using the `task` function.
|
|
14
14
|
*
|
|
15
|
-
* !!! warning "Beta"
|
|
16
|
-
* The Functional API is currently in beta and is subject to change.
|
|
17
|
-
*
|
|
18
|
-
* @beta
|
|
19
|
-
*
|
|
20
15
|
* Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
|
|
21
16
|
* A task can be called like a regular function with the following differences:
|
|
22
17
|
*
|
|
@@ -75,11 +70,6 @@ exports.task = task;
|
|
|
75
70
|
/**
|
|
76
71
|
* Define a LangGraph workflow using the `entrypoint` function.
|
|
77
72
|
*
|
|
78
|
-
* !!! warning "Beta"
|
|
79
|
-
* The Functional API is currently in beta and is subject to change.
|
|
80
|
-
*
|
|
81
|
-
* @beta
|
|
82
|
-
*
|
|
83
73
|
* ### Function signature
|
|
84
74
|
*
|
|
85
75
|
* The wrapped function must accept at most **two parameters**. The first parameter
|
|
@@ -251,11 +241,6 @@ exports.entrypoint.final = function final({ value, save, }) {
|
|
|
251
241
|
* This function allows workflows to access state that was saved in previous runs
|
|
252
242
|
* using {@link entrypoint.final}.
|
|
253
243
|
*
|
|
254
|
-
* !!! warning "Beta"
|
|
255
|
-
* The Functional API is currently in beta and is subject to change.
|
|
256
|
-
*
|
|
257
|
-
* @beta
|
|
258
|
-
*
|
|
259
244
|
* @typeParam StateT - The type of the state that was previously saved
|
|
260
245
|
* @returns The previous saved state from the last invocation of the current thread
|
|
261
246
|
*
|
package/dist/func/index.d.ts
CHANGED
|
@@ -8,35 +8,21 @@ import { LastValue } from "../channels/last_value.js";
|
|
|
8
8
|
import { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from "./types.js";
|
|
9
9
|
/**
|
|
10
10
|
* Options for the {@link task} function
|
|
11
|
-
*
|
|
12
|
-
* !!! warning "Beta"
|
|
13
|
-
* The Functional API is currently in beta and is subject to change.
|
|
14
|
-
*
|
|
15
|
-
* @beta
|
|
16
11
|
*/
|
|
17
12
|
export type TaskOptions = {
|
|
18
13
|
/**
|
|
19
14
|
* The name of the task, analogous to the node name in {@link StateGraph}.
|
|
20
|
-
*
|
|
21
|
-
* @beta
|
|
22
15
|
*/
|
|
23
16
|
name: string;
|
|
24
17
|
/**
|
|
25
18
|
* The retry policy for the task. Configures how many times and under what conditions
|
|
26
19
|
* the task should be retried if it fails.
|
|
27
|
-
*
|
|
28
|
-
* @beta
|
|
29
20
|
*/
|
|
30
21
|
retry?: RetryPolicy;
|
|
31
22
|
};
|
|
32
23
|
/**
|
|
33
24
|
* Define a LangGraph task using the `task` function.
|
|
34
25
|
*
|
|
35
|
-
* !!! warning "Beta"
|
|
36
|
-
* The Functional API is currently in beta and is subject to change.
|
|
37
|
-
*
|
|
38
|
-
* @beta
|
|
39
|
-
*
|
|
40
26
|
* Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
|
|
41
27
|
* A task can be called like a regular function with the following differences:
|
|
42
28
|
*
|
|
@@ -83,31 +69,20 @@ export type TaskOptions = {
|
|
|
83
69
|
export declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;
|
|
84
70
|
/**
|
|
85
71
|
* Options for the {@link entrypoint} function
|
|
86
|
-
*
|
|
87
|
-
* !!! warning "Beta"
|
|
88
|
-
* The Functional API is currently in beta and is subject to change.
|
|
89
|
-
*
|
|
90
|
-
* @beta
|
|
91
72
|
*/
|
|
92
73
|
export type EntrypointOptions = {
|
|
93
74
|
/**
|
|
94
75
|
* The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.
|
|
95
76
|
* This name is used for logging, debugging, and checkpoint identification.
|
|
96
|
-
*
|
|
97
|
-
* @beta
|
|
98
77
|
*/
|
|
99
78
|
name: string;
|
|
100
79
|
/**
|
|
101
80
|
* The checkpointer for the {@link entrypoint}. Used to save and restore state between
|
|
102
81
|
* invocations of the workflow.
|
|
103
|
-
*
|
|
104
|
-
* @beta
|
|
105
82
|
*/
|
|
106
83
|
checkpointer?: BaseCheckpointSaver;
|
|
107
84
|
/**
|
|
108
85
|
* The store for the {@link entrypoint}. Used to persist data across workflow runs.
|
|
109
|
-
*
|
|
110
|
-
* @beta
|
|
111
86
|
*/
|
|
112
87
|
store?: BaseStore;
|
|
113
88
|
};
|
|
@@ -125,11 +100,6 @@ export interface EntrypointFunction {
|
|
|
125
100
|
* as well as a separate state value to persist to the checkpoint. This allows workflows
|
|
126
101
|
* to maintain state between runs while returning different values to the caller.
|
|
127
102
|
*
|
|
128
|
-
* !!! warning "Beta"
|
|
129
|
-
* The Functional API is currently in beta and is subject to change.
|
|
130
|
-
*
|
|
131
|
-
* @beta
|
|
132
|
-
*
|
|
133
103
|
* @typeParam ValueT - The type of the value to return to the caller
|
|
134
104
|
* @typeParam SaveT - The type of the state to save to the checkpoint
|
|
135
105
|
* @param value - The value to return to the caller
|
|
@@ -152,11 +122,6 @@ export interface EntrypointFunction {
|
|
|
152
122
|
/**
|
|
153
123
|
* Define a LangGraph workflow using the `entrypoint` function.
|
|
154
124
|
*
|
|
155
|
-
* !!! warning "Beta"
|
|
156
|
-
* The Functional API is currently in beta and is subject to change.
|
|
157
|
-
*
|
|
158
|
-
* @beta
|
|
159
|
-
*
|
|
160
125
|
* ### Function signature
|
|
161
126
|
*
|
|
162
127
|
* The wrapped function must accept at most **two parameters**. The first parameter
|
|
@@ -293,11 +258,6 @@ export declare const entrypoint: EntrypointFunction;
|
|
|
293
258
|
* This function allows workflows to access state that was saved in previous runs
|
|
294
259
|
* using {@link entrypoint.final}.
|
|
295
260
|
*
|
|
296
|
-
* !!! warning "Beta"
|
|
297
|
-
* The Functional API is currently in beta and is subject to change.
|
|
298
|
-
*
|
|
299
|
-
* @beta
|
|
300
|
-
*
|
|
301
261
|
* @typeParam StateT - The type of the state that was previously saved
|
|
302
262
|
* @returns The previous saved state from the last invocation of the current thread
|
|
303
263
|
*
|
package/dist/func/index.js
CHANGED
|
@@ -9,11 +9,6 @@ import { isAsyncGeneratorFunction, isGeneratorFunction } from "../utils.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Define a LangGraph task using the `task` function.
|
|
11
11
|
*
|
|
12
|
-
* !!! warning "Beta"
|
|
13
|
-
* The Functional API is currently in beta and is subject to change.
|
|
14
|
-
*
|
|
15
|
-
* @beta
|
|
16
|
-
*
|
|
17
12
|
* Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
|
|
18
13
|
* A task can be called like a regular function with the following differences:
|
|
19
14
|
*
|
|
@@ -71,11 +66,6 @@ export function task(optionsOrName, func) {
|
|
|
71
66
|
/**
|
|
72
67
|
* Define a LangGraph workflow using the `entrypoint` function.
|
|
73
68
|
*
|
|
74
|
-
* !!! warning "Beta"
|
|
75
|
-
* The Functional API is currently in beta and is subject to change.
|
|
76
|
-
*
|
|
77
|
-
* @beta
|
|
78
|
-
*
|
|
79
69
|
* ### Function signature
|
|
80
70
|
*
|
|
81
71
|
* The wrapped function must accept at most **two parameters**. The first parameter
|
|
@@ -247,11 +237,6 @@ entrypoint.final = function final({ value, save, }) {
|
|
|
247
237
|
* This function allows workflows to access state that was saved in previous runs
|
|
248
238
|
* using {@link entrypoint.final}.
|
|
249
239
|
*
|
|
250
|
-
* !!! warning "Beta"
|
|
251
|
-
* The Functional API is currently in beta and is subject to change.
|
|
252
|
-
*
|
|
253
|
-
* @beta
|
|
254
|
-
*
|
|
255
240
|
* @typeParam StateT - The type of the state that was previously saved
|
|
256
241
|
* @returns The previous saved state from the last invocation of the current thread
|
|
257
242
|
*
|
package/dist/prebuilt/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toolsCondition = exports.ToolNode = exports.ToolExecutor = exports.createReactAgent = exports.createFunctionCallingExecutor = exports.createAgentExecutor = void 0;
|
|
3
|
+
exports.toolsCondition = exports.ToolNode = exports.ToolExecutor = exports.createReactAgentAnnotation = exports.createReactAgent = exports.createFunctionCallingExecutor = exports.createAgentExecutor = void 0;
|
|
4
4
|
var agent_executor_js_1 = require("./agent_executor.cjs");
|
|
5
5
|
Object.defineProperty(exports, "createAgentExecutor", { enumerable: true, get: function () { return agent_executor_js_1.createAgentExecutor; } });
|
|
6
6
|
var chat_agent_executor_js_1 = require("./chat_agent_executor.cjs");
|
|
7
7
|
Object.defineProperty(exports, "createFunctionCallingExecutor", { enumerable: true, get: function () { return chat_agent_executor_js_1.createFunctionCallingExecutor; } });
|
|
8
8
|
var react_agent_executor_js_1 = require("./react_agent_executor.cjs");
|
|
9
9
|
Object.defineProperty(exports, "createReactAgent", { enumerable: true, get: function () { return react_agent_executor_js_1.createReactAgent; } });
|
|
10
|
+
Object.defineProperty(exports, "createReactAgentAnnotation", { enumerable: true, get: function () { return react_agent_executor_js_1.createReactAgentAnnotation; } });
|
|
10
11
|
var tool_executor_js_1 = require("./tool_executor.cjs");
|
|
11
12
|
Object.defineProperty(exports, "ToolExecutor", { enumerable: true, get: function () { return tool_executor_js_1.ToolExecutor; } });
|
|
12
13
|
var tool_node_js_1 = require("./tool_node.cjs");
|
package/dist/prebuilt/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type AgentExecutorState, createAgentExecutor, } from "./agent_executor.js";
|
|
2
2
|
export { type FunctionCallingExecutorState, createFunctionCallingExecutor, } from "./chat_agent_executor.js";
|
|
3
|
-
export { type AgentState, type CreateReactAgentParams, createReactAgent, } from "./react_agent_executor.js";
|
|
3
|
+
export { type AgentState, type CreateReactAgentParams, createReactAgent, createReactAgentAnnotation, } from "./react_agent_executor.js";
|
|
4
4
|
export { type ToolExecutorArgs, type ToolInvocationInterface, ToolExecutor, } from "./tool_executor.js";
|
|
5
5
|
export { ToolNode, toolsCondition, type ToolNodeOptions } from "./tool_node.js";
|
|
6
6
|
export type { HumanInterruptConfig, ActionRequest, HumanInterrupt, HumanResponse, } from "./interrupt.js";
|
package/dist/prebuilt/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createAgentExecutor, } from "./agent_executor.js";
|
|
2
2
|
export { createFunctionCallingExecutor, } from "./chat_agent_executor.js";
|
|
3
|
-
export { createReactAgent, } from "./react_agent_executor.js";
|
|
3
|
+
export { createReactAgent, createReactAgentAnnotation, } from "./react_agent_executor.js";
|
|
4
4
|
export { ToolExecutor, } from "./tool_executor.js";
|
|
5
5
|
export { ToolNode, toolsCondition } from "./tool_node.js";
|
|
@@ -228,7 +228,10 @@ function createReactAgent(params) {
|
|
|
228
228
|
};
|
|
229
229
|
const callModel = async (state, config) => {
|
|
230
230
|
// TODO: Auto-promote streaming.
|
|
231
|
-
|
|
231
|
+
const response = (await modelRunnable.invoke(state, config));
|
|
232
|
+
// add agent name to the AIMessage
|
|
233
|
+
response.name = name;
|
|
234
|
+
return { messages: [response] };
|
|
232
235
|
};
|
|
233
236
|
const workflow = new index_js_1.StateGraph(stateSchema ?? (0, exports.createReactAgentAnnotation)())
|
|
234
237
|
.addNode("agent", callModel)
|
|
@@ -127,4 +127,4 @@ export type CreateReactAgentParams<A extends AnnotationRoot<any> = AnnotationRoo
|
|
|
127
127
|
* // Returns the messages in the state at each step of execution
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
|
-
export declare function createReactAgent<A extends AnnotationRoot<any> =
|
|
130
|
+
export declare function createReactAgent<A extends AnnotationRoot<any> = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>>(params: CreateReactAgentParams<A, StructuredResponseFormat>): CompiledStateGraph<A["State"], A["Update"], any, typeof MessagesAnnotation.spec & A["spec"], ReturnType<typeof createReactAgentAnnotation<StructuredResponseFormat>>["spec"] & A["spec"]>;
|
|
@@ -224,7 +224,10 @@ export function createReactAgent(params) {
|
|
|
224
224
|
};
|
|
225
225
|
const callModel = async (state, config) => {
|
|
226
226
|
// TODO: Auto-promote streaming.
|
|
227
|
-
|
|
227
|
+
const response = (await modelRunnable.invoke(state, config));
|
|
228
|
+
// add agent name to the AIMessage
|
|
229
|
+
response.name = name;
|
|
230
|
+
return { messages: [response] };
|
|
228
231
|
};
|
|
229
232
|
const workflow = new StateGraph(stateSchema ?? createReactAgentAnnotation())
|
|
230
233
|
.addNode("agent", callModel)
|