@langchain/langgraph 0.3.8 → 0.3.10
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/CHANGELOG.md +21 -0
- package/README.md +28 -21
- package/dist/constants.cjs +27 -2
- package/dist/constants.d.ts +16 -1
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -1
- package/dist/graph/messages_annotation.cjs +22 -13
- package/dist/graph/messages_annotation.d.ts +16 -1
- package/dist/graph/messages_annotation.js +20 -11
- package/dist/graph/messages_annotation.js.map +1 -1
- package/dist/graph/zod/meta.d.ts +5 -0
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/zod-registry.d.ts +5 -0
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/prebuilt/react_agent_executor.cjs +13 -9
- package/dist/prebuilt/react_agent_executor.d.ts +13 -8
- package/dist/prebuilt/react_agent_executor.js +13 -9
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/pregel/index.cjs +4 -6
- package/dist/pregel/index.d.ts +6 -6
- package/dist/pregel/index.js +4 -6
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/runner.cjs +27 -38
- package/dist/pregel/runner.js +27 -38
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/types.d.ts +0 -4
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/utils/index.cjs +15 -12
- package/dist/pregel/utils/index.d.ts +5 -2
- package/dist/pregel/utils/index.js +15 -12
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/web.cjs +2 -1
- package/dist/web.d.ts +1 -1
- package/dist/web.js +1 -1
- package/dist/web.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @langchain/langgraph
|
|
2
2
|
|
|
3
|
+
## 0.3.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a12c1fb: fix(langgraph): stop suggesting public properties and methods of Command when calling invoke
|
|
8
|
+
- Updated dependencies [ee1defa]
|
|
9
|
+
- @langchain/langgraph-sdk@0.0.98
|
|
10
|
+
|
|
11
|
+
## 0.3.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 430ae93: feat(langgraph): validate if messages present in user provided schema
|
|
16
|
+
- 4aed3f4: fix(langgraph): dispose unused combined signals
|
|
17
|
+
- 02f9e02: fix(langgraph): preModelHook `llmInputMessages` should not keep concatenating messages
|
|
18
|
+
- 6e616f5: fix(langgraph): respect strict option in responseFormat inside createReactAgent
|
|
19
|
+
- 6812b50: feat(langgraph): allow extending state with Zod schema
|
|
20
|
+
- 8166703: add UpdateType type utility for Zod, improve Zod 4 and Zod 4 mini support
|
|
21
|
+
- Updated dependencies [53b8c30]
|
|
22
|
+
- @langchain/langgraph-sdk@0.0.96
|
|
23
|
+
|
|
3
24
|
## 0.3.8
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -24,21 +24,27 @@ import { tool } from "@langchain/core/tools";
|
|
|
24
24
|
|
|
25
25
|
import { z } from "zod";
|
|
26
26
|
|
|
27
|
-
const search = tool(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const search = tool(
|
|
28
|
+
async ({ query }) => {
|
|
29
|
+
if (
|
|
30
|
+
query.toLowerCase().includes("sf") ||
|
|
31
|
+
query.toLowerCase().includes("san francisco")
|
|
32
|
+
) {
|
|
33
|
+
return "It's 60 degrees and foggy.";
|
|
34
|
+
}
|
|
35
|
+
return "It's 90 degrees and sunny.";
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "search",
|
|
39
|
+
description: "Call to surf the web.",
|
|
40
|
+
schema: z.object({
|
|
41
|
+
query: z.string().describe("The query to use in your search."),
|
|
42
|
+
}),
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
}, {
|
|
33
|
-
name: "search",
|
|
34
|
-
description: "Call to surf the web.",
|
|
35
|
-
schema: z.object({
|
|
36
|
-
query: z.string().describe("The query to use in your search."),
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
44
|
+
);
|
|
39
45
|
|
|
40
|
-
const model =
|
|
41
|
-
model: "claude-3-7-sonnet-latest"
|
|
46
|
+
const model = new ChatAnthropic({
|
|
47
|
+
model: "claude-3-7-sonnet-latest",
|
|
42
48
|
});
|
|
43
49
|
|
|
44
50
|
const agent = createReactAgent({
|
|
@@ -46,14 +52,14 @@ const agent = createReactAgent({
|
|
|
46
52
|
tools: [search],
|
|
47
53
|
});
|
|
48
54
|
|
|
49
|
-
const result = await agent.invoke(
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
const result = await agent.invoke({
|
|
56
|
+
messages: [
|
|
57
|
+
{
|
|
52
58
|
role: "user",
|
|
53
|
-
content: "what is the weather in sf"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
);
|
|
59
|
+
content: "what is the weather in sf",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
57
63
|
```
|
|
58
64
|
|
|
59
65
|
## Full-stack Quickstart
|
|
@@ -105,6 +111,7 @@ LangGraph Platform can help engineering teams:
|
|
|
105
111
|
|
|
106
112
|
## Additional resources
|
|
107
113
|
|
|
114
|
+
- [LangChain Forum](https://forum.langchain.com/): Connect with the community and share all of your technical questions, ideas, and feedback.
|
|
108
115
|
- [LangChain Academy](https://academy.langchain.com/courses/intro-to-langgraph): Learn the basics of LangGraph in our free, structured course.
|
|
109
116
|
- [Tutorials](https://langchain-ai.github.io/langgraphjs/tutorials/): Simple walkthroughs with guided examples on getting started with LangGraph.
|
|
110
117
|
- [Templates](https://langchain-ai.github.io/langgraphjs/concepts/template_applications/): Pre-built reference apps for common agentic workflows (e.g. ReAct agent, memory, retrieval etc.) that can be cloned and adapted.
|
|
@@ -114,4 +121,4 @@ LangGraph Platform can help engineering teams:
|
|
|
114
121
|
|
|
115
122
|
## Acknowledgements
|
|
116
123
|
|
|
117
|
-
LangGraph is inspired by [Pregel](https://research.google/pubs/pub37252/) and [Apache Beam](https://beam.apache.org/). The public interface draws inspiration from [NetworkX](https://networkx.org/documentation/latest/). LangGraph is built by LangChain Inc, the creators of LangChain, but can be used without LangChain.
|
|
124
|
+
LangGraph is inspired by [Pregel](https://research.google/pubs/pub37252/) and [Apache Beam](https://beam.apache.org/). The public interface draws inspiration from [NetworkX](https://networkx.org/documentation/latest/). LangGraph is built by LangChain Inc, the creators of LangChain, but can be used without LangChain.
|
package/dist/constants.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Command = exports.Send = exports.CHECKPOINT_NAMESPACE_END = exports.CHECKPOINT_NAMESPACE_SEPARATOR = exports.RESERVED = exports.NULL_TASK_ID = exports.TASK_NAMESPACE = exports.PULL = exports.PUSH = exports.TASKS = exports.SELF = exports.TAG_NOSTREAM = exports.TAG_HIDDEN = exports.RECURSION_LIMIT_DEFAULT = exports.RUNTIME_PLACEHOLDER = exports.PREVIOUS = exports.RETURN = exports.NO_WRITES = exports.RESUME = exports.INTERRUPT = exports.CONFIG_KEY_ABORT_SIGNALS = exports.CONFIG_KEY_CHECKPOINT_MAP = exports.CONFIG_KEY_NODE_FINISHED = exports.CONFIG_KEY_CHECKPOINT_NS = exports.CONFIG_KEY_CHECKPOINT_ID = exports.CONFIG_KEY_CHECKPOINT_DURING = exports.CONFIG_KEY_PREVIOUS_STATE = exports.CONFIG_KEY_SCRATCHPAD = exports.CONFIG_KEY_RESUME_MAP = exports.CONFIG_KEY_RESUME_VALUE = exports.CONFIG_KEY_STREAM = exports.CONFIG_KEY_TASK_ID = exports.CONFIG_KEY_RESUMING = exports.CONFIG_KEY_CHECKPOINTER = exports.CONFIG_KEY_READ = exports.CONFIG_KEY_CALL = exports.CONFIG_KEY_SEND = exports.CACHE_NS_WRITES = exports.ERROR = exports.COPY = exports.INPUT = exports.END = exports.START = void 0;
|
|
4
|
+
exports.Command = exports.Send = exports.CommandInstance = exports.CHECKPOINT_NAMESPACE_END = exports.CHECKPOINT_NAMESPACE_SEPARATOR = exports.RESERVED = exports.NULL_TASK_ID = exports.TASK_NAMESPACE = exports.PULL = exports.PUSH = exports.TASKS = exports.SELF = exports.TAG_NOSTREAM = exports.TAG_HIDDEN = exports.RECURSION_LIMIT_DEFAULT = exports.RUNTIME_PLACEHOLDER = exports.PREVIOUS = exports.RETURN = exports.NO_WRITES = exports.RESUME = exports.INTERRUPT = exports.CONFIG_KEY_ABORT_SIGNALS = exports.CONFIG_KEY_CHECKPOINT_MAP = exports.CONFIG_KEY_NODE_FINISHED = exports.CONFIG_KEY_CHECKPOINT_NS = exports.CONFIG_KEY_CHECKPOINT_ID = exports.CONFIG_KEY_CHECKPOINT_DURING = exports.CONFIG_KEY_PREVIOUS_STATE = exports.CONFIG_KEY_SCRATCHPAD = exports.CONFIG_KEY_RESUME_MAP = exports.CONFIG_KEY_RESUME_VALUE = exports.CONFIG_KEY_STREAM = exports.CONFIG_KEY_TASK_ID = exports.CONFIG_KEY_RESUMING = exports.CONFIG_KEY_CHECKPOINTER = exports.CONFIG_KEY_READ = exports.CONFIG_KEY_CALL = exports.CONFIG_KEY_SEND = exports.CACHE_NS_WRITES = exports.ERROR = exports.COPY = exports.INPUT = exports.END = exports.START = void 0;
|
|
4
5
|
exports._isSendInterface = _isSendInterface;
|
|
5
6
|
exports._isSend = _isSend;
|
|
6
7
|
exports.isInterrupted = isInterrupted;
|
|
@@ -80,6 +81,29 @@ exports.RESERVED = [
|
|
|
80
81
|
];
|
|
81
82
|
exports.CHECKPOINT_NAMESPACE_SEPARATOR = "|";
|
|
82
83
|
exports.CHECKPOINT_NAMESPACE_END = ":";
|
|
84
|
+
/** @internal */
|
|
85
|
+
const COMMAND_SYMBOL = Symbol.for("langgraph.command");
|
|
86
|
+
/**
|
|
87
|
+
* Instance of a {@link Command} class.
|
|
88
|
+
*
|
|
89
|
+
* This is used to avoid IntelliSense suggesting public fields
|
|
90
|
+
* of {@link Command} class when a plain object is expected.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link Command}
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
class CommandInstance {
|
|
96
|
+
constructor() {
|
|
97
|
+
Object.defineProperty(this, _a, {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.CommandInstance = CommandInstance;
|
|
106
|
+
_a = COMMAND_SYMBOL;
|
|
83
107
|
function _isSendInterface(x) {
|
|
84
108
|
const operation = x;
|
|
85
109
|
return (operation !== null &&
|
|
@@ -251,8 +275,9 @@ function isInterrupted(values) {
|
|
|
251
275
|
* // { foo: 'a|c' } and { foo: 'a|b' }
|
|
252
276
|
* ```
|
|
253
277
|
*/
|
|
254
|
-
class Command {
|
|
278
|
+
class Command extends CommandInstance {
|
|
255
279
|
constructor(args) {
|
|
280
|
+
super();
|
|
256
281
|
Object.defineProperty(this, "lg_name", {
|
|
257
282
|
enumerable: true,
|
|
258
283
|
configurable: true,
|
package/dist/constants.d.ts
CHANGED
|
@@ -50,6 +50,20 @@ export declare const NULL_TASK_ID = "00000000-0000-0000-0000-000000000000";
|
|
|
50
50
|
export declare const RESERVED: string[];
|
|
51
51
|
export declare const CHECKPOINT_NAMESPACE_SEPARATOR = "|";
|
|
52
52
|
export declare const CHECKPOINT_NAMESPACE_END = ":";
|
|
53
|
+
/** @internal */
|
|
54
|
+
declare const COMMAND_SYMBOL: unique symbol;
|
|
55
|
+
/**
|
|
56
|
+
* Instance of a {@link Command} class.
|
|
57
|
+
*
|
|
58
|
+
* This is used to avoid IntelliSense suggesting public fields
|
|
59
|
+
* of {@link Command} class when a plain object is expected.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link Command}
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare class CommandInstance {
|
|
65
|
+
[COMMAND_SYMBOL]: true;
|
|
66
|
+
}
|
|
53
67
|
export interface SendInterface<Node extends string = string, Args = any> {
|
|
54
68
|
node: Node;
|
|
55
69
|
args: Args;
|
|
@@ -233,7 +247,7 @@ export type CommandParams<Resume = unknown, Update extends Record<string, unknow
|
|
|
233
247
|
* // { foo: 'a|c' } and { foo: 'a|b' }
|
|
234
248
|
* ```
|
|
235
249
|
*/
|
|
236
|
-
export declare class Command<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> {
|
|
250
|
+
export declare class Command<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> extends CommandInstance {
|
|
237
251
|
readonly lg_name = "Command";
|
|
238
252
|
lc_direct_tool_output: boolean;
|
|
239
253
|
/**
|
|
@@ -306,3 +320,4 @@ export declare function isCommand(x: unknown): x is Command;
|
|
|
306
320
|
* @returns The converted command send tree.
|
|
307
321
|
*/
|
|
308
322
|
export declare function _deserializeCommandSendObjectGraph(x: unknown, seen?: Map<object, unknown>): unknown;
|
|
323
|
+
export {};
|
package/dist/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
/** Special reserved node name denoting the start of a graph. */
|
|
2
3
|
export const START = "__start__";
|
|
3
4
|
/** Special reserved node name denoting the end of a graph. */
|
|
@@ -72,6 +73,28 @@ export const RESERVED = [
|
|
|
72
73
|
];
|
|
73
74
|
export const CHECKPOINT_NAMESPACE_SEPARATOR = "|";
|
|
74
75
|
export const CHECKPOINT_NAMESPACE_END = ":";
|
|
76
|
+
/** @internal */
|
|
77
|
+
const COMMAND_SYMBOL = Symbol.for("langgraph.command");
|
|
78
|
+
/**
|
|
79
|
+
* Instance of a {@link Command} class.
|
|
80
|
+
*
|
|
81
|
+
* This is used to avoid IntelliSense suggesting public fields
|
|
82
|
+
* of {@link Command} class when a plain object is expected.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link Command}
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export class CommandInstance {
|
|
88
|
+
constructor() {
|
|
89
|
+
Object.defineProperty(this, _a, {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_a = COMMAND_SYMBOL;
|
|
75
98
|
export function _isSendInterface(x) {
|
|
76
99
|
const operation = x;
|
|
77
100
|
return (operation !== null &&
|
|
@@ -242,8 +265,9 @@ export function isInterrupted(values) {
|
|
|
242
265
|
* // { foo: 'a|c' } and { foo: 'a|b' }
|
|
243
266
|
* ```
|
|
244
267
|
*/
|
|
245
|
-
export class Command {
|
|
268
|
+
export class Command extends CommandInstance {
|
|
246
269
|
constructor(args) {
|
|
270
|
+
super();
|
|
247
271
|
Object.defineProperty(this, "lg_name", {
|
|
248
272
|
enumerable: true,
|
|
249
273
|
configurable: true,
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AACjC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC;AAC7B,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC;AAC/B,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AAEjC,wCAAwC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAC/C,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAC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AC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,MAAM,GAAG,CAAC,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,iBAAiB,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;YACvD,MAAM,GAAG,CAAC,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,4BAA4B;YAC5B,MAAM,GAAG,EAAE,CAAC;YACZ,yEAAyE;YACzE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YAEpB,0BAA0B;YAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5C,MAAkC,CAAC,GAAG,CAAC;oBACtC,kCAAkC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.MessagesZodState = exports.MessagesAnnotation = void 0;
|
|
5
|
-
const
|
|
4
|
+
exports.MessagesZodState = exports.MessagesZodMeta = exports.MessagesAnnotation = void 0;
|
|
5
|
+
const v3_1 = require("zod/v3");
|
|
6
6
|
const annotation_js_1 = require("./annotation.cjs");
|
|
7
7
|
const message_js_1 = require("./message.cjs");
|
|
8
8
|
const meta_js_1 = require("./zod/meta.cjs");
|
|
@@ -47,6 +47,24 @@ exports.MessagesAnnotation = annotation_js_1.Annotation.Root({
|
|
|
47
47
|
default: () => [],
|
|
48
48
|
}),
|
|
49
49
|
});
|
|
50
|
+
/**
|
|
51
|
+
* Prebuilt schema meta for Zod state definition.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { z } from "zod/v4-mini";
|
|
56
|
+
* import { MessagesZodState, StateGraph } from "@langchain/langgraph";
|
|
57
|
+
*
|
|
58
|
+
* const AgentState = z.object({
|
|
59
|
+
* messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
exports.MessagesZodMeta = {
|
|
64
|
+
reducer: { fn: message_js_1.messagesStateReducer },
|
|
65
|
+
jsonSchemaExtra: { langgraph_type: "messages" },
|
|
66
|
+
default: () => [],
|
|
67
|
+
};
|
|
50
68
|
/**
|
|
51
69
|
* Prebuilt state object that uses Zod to combine returned messages.
|
|
52
70
|
* This utility is synonymous with the `MessagesAnnotation` annotation,
|
|
@@ -86,16 +104,7 @@ exports.MessagesAnnotation = annotation_js_1.Annotation.Root({
|
|
|
86
104
|
* ...
|
|
87
105
|
* ```
|
|
88
106
|
*/
|
|
89
|
-
exports.MessagesZodState =
|
|
90
|
-
messages: (0, meta_js_1.withLangGraph)(
|
|
91
|
-
reducer: {
|
|
92
|
-
schema: zod_1.z.custom(),
|
|
93
|
-
fn: message_js_1.messagesStateReducer,
|
|
94
|
-
},
|
|
95
|
-
jsonSchemaExtra: {
|
|
96
|
-
langgraph_type: "messages",
|
|
97
|
-
},
|
|
98
|
-
default: () => [],
|
|
99
|
-
}),
|
|
107
|
+
exports.MessagesZodState = v3_1.z.object({
|
|
108
|
+
messages: (0, meta_js_1.withLangGraph)(v3_1.z.custom(), exports.MessagesZodMeta),
|
|
100
109
|
});
|
|
101
110
|
//# sourceMappingURL=messages_annotation.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseMessage } from "@langchain/core/messages";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
3
|
import { Messages } from "./message.js";
|
|
4
|
+
import { SchemaMeta } from "./zod/meta.js";
|
|
4
5
|
/**
|
|
5
6
|
* Prebuilt state annotation that combines returned messages.
|
|
6
7
|
* Can handle standard messages and special modifiers like {@link RemoveMessage}
|
|
@@ -39,6 +40,20 @@ import { Messages } from "./message.js";
|
|
|
39
40
|
export declare const MessagesAnnotation: import("./annotation.js").AnnotationRoot<{
|
|
40
41
|
messages: import("../web.js").BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
41
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Prebuilt schema meta for Zod state definition.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { z } from "zod/v4-mini";
|
|
49
|
+
* import { MessagesZodState, StateGraph } from "@langchain/langgraph";
|
|
50
|
+
*
|
|
51
|
+
* const AgentState = z.object({
|
|
52
|
+
* messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;
|
|
42
57
|
/**
|
|
43
58
|
* Prebuilt state object that uses Zod to combine returned messages.
|
|
44
59
|
* This utility is synonymous with the `MessagesAnnotation` annotation,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
3
|
import { Annotation } from "./annotation.js";
|
|
4
4
|
import { messagesStateReducer } from "./message.js";
|
|
5
5
|
import { withLangGraph } from "./zod/meta.js";
|
|
@@ -44,6 +44,24 @@ export const MessagesAnnotation = Annotation.Root({
|
|
|
44
44
|
default: () => [],
|
|
45
45
|
}),
|
|
46
46
|
});
|
|
47
|
+
/**
|
|
48
|
+
* Prebuilt schema meta for Zod state definition.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { z } from "zod/v4-mini";
|
|
53
|
+
* import { MessagesZodState, StateGraph } from "@langchain/langgraph";
|
|
54
|
+
*
|
|
55
|
+
* const AgentState = z.object({
|
|
56
|
+
* messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export const MessagesZodMeta = {
|
|
61
|
+
reducer: { fn: messagesStateReducer },
|
|
62
|
+
jsonSchemaExtra: { langgraph_type: "messages" },
|
|
63
|
+
default: () => [],
|
|
64
|
+
};
|
|
47
65
|
/**
|
|
48
66
|
* Prebuilt state object that uses Zod to combine returned messages.
|
|
49
67
|
* This utility is synonymous with the `MessagesAnnotation` annotation,
|
|
@@ -84,15 +102,6 @@ export const MessagesAnnotation = Annotation.Root({
|
|
|
84
102
|
* ```
|
|
85
103
|
*/
|
|
86
104
|
export const MessagesZodState = z.object({
|
|
87
|
-
messages: withLangGraph(z.custom(),
|
|
88
|
-
reducer: {
|
|
89
|
-
schema: z.custom(),
|
|
90
|
-
fn: messagesStateReducer,
|
|
91
|
-
},
|
|
92
|
-
jsonSchemaExtra: {
|
|
93
|
-
langgraph_type: "messages",
|
|
94
|
-
},
|
|
95
|
-
default: () => [],
|
|
96
|
-
}),
|
|
105
|
+
messages: withLangGraph(z.custom(), MessagesZodMeta),
|
|
97
106
|
});
|
|
98
107
|
//# sourceMappingURL=messages_annotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.js","sourceRoot":"","sources":["../../src/graph/messages_annotation.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAG1C,OAAO,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"messages_annotation.js","sourceRoot":"","sources":["../../src/graph/messages_annotation.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAG1C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAY,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,IAAI,CAAC;IAChD,QAAQ,EAAE,UAAU,CAA0B;QAC5C,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwC;IAClE,OAAO,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE;IACrC,eAAe,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;IAC/C,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAAiB,EAAE,eAAe,CAAC;CACpE,CAAC,CAAC"}
|
package/dist/graph/zod/meta.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { InteropZodObject, InteropZodType, InteropZodObjectShape } from "@langchain/core/utils/types";
|
|
2
2
|
import { BaseChannel } from "../../channels/base.js";
|
|
3
3
|
export declare const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
|
|
4
|
+
/** @internal */
|
|
4
5
|
export type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {
|
|
5
6
|
lg_reducer_schema: TReducerSchema;
|
|
6
7
|
};
|
|
8
|
+
/** @internal */
|
|
7
9
|
export type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {
|
|
8
10
|
[key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never;
|
|
9
11
|
};
|
|
12
|
+
export type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {
|
|
13
|
+
[key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never;
|
|
14
|
+
};
|
|
10
15
|
export interface SchemaMeta<TValue = any, TUpdate = TValue> {
|
|
11
16
|
jsonSchemaExtra?: {
|
|
12
17
|
langgraph_nodes?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/graph/zod/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EAEvB,aAAa,EACb,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/graph/zod/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EAEvB,aAAa,EACb,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,uBA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G,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAkB3D,MAAM,UAAU,aAAa,CAK3B,MAAe,EACf,IAAiC;IAEjC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAC9D,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;YAC/B,6CAA6C;YAC7C,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC;QACpC,CAAC;IACH,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YAC9C,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,MAAM;SAClD,CAAC,CAAC;QACH,kBAAkB,CAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACzD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -27,4 +27,9 @@ declare module "zod/v4" {
|
|
|
27
27
|
register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
declare module "zod/v4-mini" {
|
|
31
|
+
interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
|
32
|
+
register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
30
35
|
export declare const registry: LanggraphZodMetaRegistry<SchemaMeta<any, any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.js","sourceRoot":"","sources":["../../../src/graph/zod/zod-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-registry.js","sourceRoot":"","sources":["../../../src/graph/zod/zod-registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAY,YAAY,EAAY,MAAM,aAAa,CAAC;AAC/D,OAAO,EAIL,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAGX,SAAQ,YAA0B;IAClC;;;;OAIG;IACH,YAAsB,MAA0B;QAC9C,KAAK,EAAE,CAAC;QADE;;;;mBAAU,MAAM;WAAoB;QAE9C,4CAA4C;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAA+C,CAAC;IAC1E,CAAC;IAED,GAAG,CACD,MAAS,EACT,GAAG,KAEoB;QAEvB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;YACrC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;YAC9D,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC/B,6CAA6C;gBAC7C,SAAS,CAAC,OAAO,GAAG,kBAAkB,CAAC;YACzC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAoDD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -247,7 +247,7 @@ const createReactAgentAnnotation = () => annotation_js_1.Annotation.Root({
|
|
|
247
247
|
exports.createReactAgentAnnotation = createReactAgentAnnotation;
|
|
248
248
|
const PreHookAnnotation = annotation_js_1.Annotation.Root({
|
|
249
249
|
llmInputMessages: (0, annotation_js_1.Annotation)({
|
|
250
|
-
reducer: message_js_1.messagesStateReducer,
|
|
250
|
+
reducer: (_, update) => (0, message_js_1.messagesStateReducer)([], update),
|
|
251
251
|
default: () => [],
|
|
252
252
|
}),
|
|
253
253
|
});
|
|
@@ -343,15 +343,16 @@ function createReactAgent(params) {
|
|
|
343
343
|
}
|
|
344
344
|
const messages = [...state.messages];
|
|
345
345
|
let modelWithStructuredOutput;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
const model = await _getModel(llm);
|
|
347
|
+
if (typeof responseFormat === "object" && "schema" in responseFormat) {
|
|
348
|
+
const { prompt, schema, ...options } = responseFormat;
|
|
349
|
+
modelWithStructuredOutput = model.withStructuredOutput(schema, options);
|
|
350
|
+
if (prompt != null) {
|
|
351
|
+
messages.unshift(new messages_1.SystemMessage({ content: prompt }));
|
|
352
|
+
}
|
|
352
353
|
}
|
|
353
354
|
else {
|
|
354
|
-
modelWithStructuredOutput =
|
|
355
|
+
modelWithStructuredOutput = model.withStructuredOutput(responseFormat);
|
|
355
356
|
}
|
|
356
357
|
const response = await modelWithStructuredOutput.invoke(messages, config);
|
|
357
358
|
return { structuredResponse: response };
|
|
@@ -370,6 +371,9 @@ function createReactAgent(params) {
|
|
|
370
371
|
};
|
|
371
372
|
const schema = stateSchema ?? (0, exports.createReactAgentAnnotation)();
|
|
372
373
|
const workflow = new index_js_1.StateGraph(schema).addNode("tools", toolNode);
|
|
374
|
+
if (!("messages" in workflow._schemaDefinition)) {
|
|
375
|
+
throw new Error("Missing required `messages` key in state schema.");
|
|
376
|
+
}
|
|
373
377
|
const allNodeWorkflows = workflow;
|
|
374
378
|
const conditionalMap = (map) => {
|
|
375
379
|
return Object.fromEntries(Object.entries(map).filter(([_, v]) => v != null));
|
|
@@ -382,7 +386,7 @@ function createReactAgent(params) {
|
|
|
382
386
|
.addEdge("pre_model_hook", "agent");
|
|
383
387
|
entrypoint = "pre_model_hook";
|
|
384
388
|
inputSchema = annotation_js_1.Annotation.Root({
|
|
385
|
-
...
|
|
389
|
+
...workflow._schemaDefinition,
|
|
386
390
|
...PreHookAnnotation.spec,
|
|
387
391
|
});
|
|
388
392
|
}
|
|
@@ -3,7 +3,7 @@ import { LanguageModelLike } from "@langchain/core/language_models/base";
|
|
|
3
3
|
import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
|
|
4
4
|
import { Runnable, RunnableToolLike, RunnableSequence, RunnableBinding, type RunnableLike } from "@langchain/core/runnables";
|
|
5
5
|
import { DynamicTool, StructuredToolInterface } from "@langchain/core/tools";
|
|
6
|
-
import { InteropZodType } from "@langchain/core/utils/types";
|
|
6
|
+
import type { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
|
|
7
7
|
import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
8
8
|
import { type CompiledStateGraph, AnnotationRoot } from "../graph/index.js";
|
|
9
9
|
import { MessagesAnnotation } from "../graph/messages_annotation.js";
|
|
@@ -11,14 +11,17 @@ import { ToolNode } from "./tool_node.js";
|
|
|
11
11
|
import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
12
12
|
import { Messages } from "../graph/message.js";
|
|
13
13
|
import { START } from "../constants.js";
|
|
14
|
+
import type { InteropZodToStateDefinition } from "../graph/zod/meta.js";
|
|
14
15
|
export interface AgentState<StructuredResponseType extends Record<string, any> = Record<string, any>> {
|
|
15
16
|
messages: BaseMessage[];
|
|
16
17
|
structuredResponse: StructuredResponseType;
|
|
17
18
|
}
|
|
18
19
|
export type N = typeof START | "agent" | "tools";
|
|
19
|
-
|
|
20
|
-
prompt: string;
|
|
20
|
+
type StructuredResponseSchemaOptions<StructuredResponseType> = {
|
|
21
21
|
schema: InteropZodType<StructuredResponseType> | Record<string, any>;
|
|
22
|
+
prompt?: string;
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
[key: string]: unknown;
|
|
22
25
|
};
|
|
23
26
|
type ServerTool = Record<string, unknown>;
|
|
24
27
|
type ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;
|
|
@@ -46,7 +49,9 @@ declare const PreHookAnnotation: AnnotationRoot<{
|
|
|
46
49
|
llmInputMessages: import("../web.js").BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
47
50
|
}>;
|
|
48
51
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
49
|
-
|
|
52
|
+
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
53
|
+
type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;
|
|
54
|
+
export type CreateReactAgentParams<A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseType = Record<string, any>> = {
|
|
50
55
|
/** The chat model that can utilize OpenAI-style tool calling. */
|
|
51
56
|
llm: LanguageModelLike;
|
|
52
57
|
/** A list of tools or a ToolNode. */
|
|
@@ -102,7 +107,7 @@ export type CreateReactAgentParams<A extends AnnotationRoot<any> = AnnotationRoo
|
|
|
102
107
|
* **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.
|
|
103
108
|
* This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).
|
|
104
109
|
*/
|
|
105
|
-
responseFormat?: InteropZodType<StructuredResponseType> |
|
|
110
|
+
responseFormat?: InteropZodType<StructuredResponseType> | StructuredResponseSchemaOptions<StructuredResponseType> | Record<string, any>;
|
|
106
111
|
/**
|
|
107
112
|
* An optional name for the agent.
|
|
108
113
|
*/
|
|
@@ -119,12 +124,12 @@ export type CreateReactAgentParams<A extends AnnotationRoot<any> = AnnotationRoo
|
|
|
119
124
|
* An optional node to add before the `agent` node (i.e., the node that calls the LLM).
|
|
120
125
|
* Useful for managing long message histories (e.g., message trimming, summarization, etc.).
|
|
121
126
|
*/
|
|
122
|
-
preModelHook?: RunnableLike<A["State"] & PreHookAnnotation["State"], A["Update"] & PreHookAnnotation["Update"], LangGraphRunnableConfig>;
|
|
127
|
+
preModelHook?: RunnableLike<ToAnnotationRoot<A>["State"] & PreHookAnnotation["State"], ToAnnotationRoot<A>["Update"] & PreHookAnnotation["Update"], LangGraphRunnableConfig>;
|
|
123
128
|
/**
|
|
124
129
|
* An optional node to add after the `agent` node (i.e., the node that calls the LLM).
|
|
125
130
|
* Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.
|
|
126
131
|
*/
|
|
127
|
-
postModelHook?: RunnableLike<A["State"], A["Update"], LangGraphRunnableConfig>;
|
|
132
|
+
postModelHook?: RunnableLike<ToAnnotationRoot<A>["State"], ToAnnotationRoot<A>["Update"], LangGraphRunnableConfig>;
|
|
128
133
|
};
|
|
129
134
|
/**
|
|
130
135
|
* Creates a StateGraph agent that relies on a chat model utilizing tool calling.
|
|
@@ -168,5 +173,5 @@ export type CreateReactAgentParams<A extends AnnotationRoot<any> = AnnotationRoo
|
|
|
168
173
|
* // Returns the messages in the state at each step of execution
|
|
169
174
|
* ```
|
|
170
175
|
*/
|
|
171
|
-
export declare function createReactAgent<A extends
|
|
176
|
+
export declare function createReactAgent<A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>>(params: CreateReactAgentParams<A, StructuredResponseFormat>): CompiledStateGraph<ToAnnotationRoot<A>["State"], ToAnnotationRoot<A>["Update"], any, typeof MessagesAnnotation.spec & ToAnnotationRoot<A>["spec"], ReturnType<typeof createReactAgentAnnotation<StructuredResponseFormat>>["spec"] & ToAnnotationRoot<A>["spec"]>;
|
|
172
177
|
export {};
|