@langchain/langgraph 0.1.7 → 0.1.8
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/graph/graph.cjs
CHANGED
|
@@ -223,12 +223,6 @@ class Graph {
|
|
|
223
223
|
for (const [start] of Object.entries(this.branches)) {
|
|
224
224
|
allSources.add(start);
|
|
225
225
|
}
|
|
226
|
-
// validate sources
|
|
227
|
-
for (const node of Object.keys(this.nodes)) {
|
|
228
|
-
if (!allSources.has(node)) {
|
|
229
|
-
throw new Error(`Node \`${node}\` is a dead-end`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
226
|
for (const source of allSources) {
|
|
233
227
|
if (source !== exports.START && !(source in this.nodes)) {
|
|
234
228
|
throw new Error(`Found edge starting at unknown node \`${source}\``);
|
package/dist/graph/graph.js
CHANGED
|
@@ -219,12 +219,6 @@ export class Graph {
|
|
|
219
219
|
for (const [start] of Object.entries(this.branches)) {
|
|
220
220
|
allSources.add(start);
|
|
221
221
|
}
|
|
222
|
-
// validate sources
|
|
223
|
-
for (const node of Object.keys(this.nodes)) {
|
|
224
|
-
if (!allSources.has(node)) {
|
|
225
|
-
throw new Error(`Node \`${node}\` is a dead-end`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
222
|
for (const source of allSources) {
|
|
229
223
|
if (source !== START && !(source in this.nodes)) {
|
|
230
224
|
throw new Error(`Found edge starting at unknown node \`${source}\``);
|
|
@@ -4,16 +4,17 @@ exports.toolsCondition = exports.ToolNode = void 0;
|
|
|
4
4
|
const messages_1 = require("@langchain/core/messages");
|
|
5
5
|
const utils_js_1 = require("../utils.cjs");
|
|
6
6
|
const graph_js_1 = require("../graph/graph.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
9
|
+
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
10
|
+
* tool calls are requested, they will be run in parallel. The output will be
|
|
11
|
+
* a list of ToolMessages, one for each tool call.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
14
|
class ToolNode extends utils_js_1.RunnableCallable {
|
|
8
15
|
constructor(tools, options) {
|
|
9
16
|
const { name, tags, handleToolErrors } = options ?? {};
|
|
10
17
|
super({ name, tags, func: (input, config) => this.run(input, config) });
|
|
11
|
-
/**
|
|
12
|
-
A node that runs the tools requested in the last AIMessage. It can be used
|
|
13
|
-
either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
14
|
-
tool calls are requested, they will be run in parallel. The output will be
|
|
15
|
-
a list of ToolMessages, one for each tool call.
|
|
16
|
-
*/
|
|
17
18
|
Object.defineProperty(this, "tools", {
|
|
18
19
|
enumerable: true,
|
|
19
20
|
configurable: true,
|
|
@@ -29,11 +30,12 @@ class ToolNode extends utils_js_1.RunnableCallable {
|
|
|
29
30
|
this.tools = tools;
|
|
30
31
|
this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;
|
|
31
32
|
}
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
34
|
async run(input, config) {
|
|
33
35
|
const message = Array.isArray(input)
|
|
34
36
|
? input[input.length - 1]
|
|
35
37
|
: input.messages[input.messages.length - 1];
|
|
36
|
-
if (message
|
|
38
|
+
if (message?._getType() !== "ai") {
|
|
37
39
|
throw new Error("ToolNode only accepts AIMessages as input.");
|
|
38
40
|
}
|
|
39
41
|
const outputs = await Promise.all(message.tool_calls?.map(async (call) => {
|
|
@@ -66,7 +68,7 @@ class ToolNode extends utils_js_1.RunnableCallable {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
}) ?? []);
|
|
69
|
-
return Array.isArray(input) ? outputs : { messages: outputs };
|
|
71
|
+
return (Array.isArray(input) ? outputs : { messages: outputs });
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
exports.ToolNode = ToolNode;
|
|
@@ -9,13 +9,13 @@ export type ToolNodeOptions = {
|
|
|
9
9
|
tags?: string[];
|
|
10
10
|
handleToolErrors?: boolean;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
14
|
+
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
15
|
+
* tool calls are requested, they will be run in parallel. The output will be
|
|
16
|
+
* a list of ToolMessages, one for each tool call.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
19
19
|
tools: (StructuredToolInterface | RunnableToolLike)[];
|
|
20
20
|
handleToolErrors: boolean;
|
|
21
21
|
constructor(tools: (StructuredToolInterface | RunnableToolLike)[], options?: ToolNodeOptions);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ToolMessage, isBaseMessage, } from "@langchain/core/messages";
|
|
2
2
|
import { RunnableCallable } from "../utils.js";
|
|
3
3
|
import { END } from "../graph/graph.js";
|
|
4
|
+
/**
|
|
5
|
+
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
6
|
+
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
7
|
+
* tool calls are requested, they will be run in parallel. The output will be
|
|
8
|
+
* a list of ToolMessages, one for each tool call.
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
11
|
export class ToolNode extends RunnableCallable {
|
|
5
12
|
constructor(tools, options) {
|
|
6
13
|
const { name, tags, handleToolErrors } = options ?? {};
|
|
7
14
|
super({ name, tags, func: (input, config) => this.run(input, config) });
|
|
8
|
-
/**
|
|
9
|
-
A node that runs the tools requested in the last AIMessage. It can be used
|
|
10
|
-
either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
11
|
-
tool calls are requested, they will be run in parallel. The output will be
|
|
12
|
-
a list of ToolMessages, one for each tool call.
|
|
13
|
-
*/
|
|
14
15
|
Object.defineProperty(this, "tools", {
|
|
15
16
|
enumerable: true,
|
|
16
17
|
configurable: true,
|
|
@@ -26,11 +27,12 @@ export class ToolNode extends RunnableCallable {
|
|
|
26
27
|
this.tools = tools;
|
|
27
28
|
this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;
|
|
28
29
|
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
31
|
async run(input, config) {
|
|
30
32
|
const message = Array.isArray(input)
|
|
31
33
|
? input[input.length - 1]
|
|
32
34
|
: input.messages[input.messages.length - 1];
|
|
33
|
-
if (message
|
|
35
|
+
if (message?._getType() !== "ai") {
|
|
34
36
|
throw new Error("ToolNode only accepts AIMessages as input.");
|
|
35
37
|
}
|
|
36
38
|
const outputs = await Promise.all(message.tool_calls?.map(async (call) => {
|
|
@@ -63,7 +65,7 @@ export class ToolNode extends RunnableCallable {
|
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
}) ?? []);
|
|
66
|
-
return Array.isArray(input) ? outputs : { messages: outputs };
|
|
68
|
+
return (Array.isArray(input) ? outputs : { messages: outputs });
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
export function toolsCondition(state) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"author": "LangChain",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@langchain/core": ">=0.2.
|
|
34
|
+
"@langchain/core": ">=0.2.31 <0.3.0",
|
|
35
35
|
"@langchain/langgraph-checkpoint": "~0.0.4",
|
|
36
36
|
"@langchain/langgraph-checkpoint-sqlite": "~0.0.1",
|
|
37
37
|
"double-ended-queue": "^2.1.0-0",
|