@langchain/langgraph 0.0.30 → 0.0.32
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/README.md +75 -28
- package/dist/channels/base.cjs +14 -0
- package/dist/channels/base.d.ts +2 -0
- package/dist/channels/base.js +14 -0
- package/dist/graph/message.d.ts +1 -1
- package/dist/graph/state.cjs +36 -2
- package/dist/graph/state.d.ts +23 -9
- package/dist/graph/state.js +34 -1
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -1
- package/dist/prebuilt/agent_executor.d.ts +1 -1
- package/dist/pregel/index.cjs +26 -21
- package/dist/pregel/index.js +26 -21
- package/package.json +9 -16
- package/dist/tests/channels.test.d.ts +0 -1
- package/dist/tests/channels.test.js +0 -151
- package/dist/tests/chatbot.int.test.d.ts +0 -1
- package/dist/tests/chatbot.int.test.js +0 -66
- package/dist/tests/checkpoints.test.d.ts +0 -1
- package/dist/tests/checkpoints.test.js +0 -178
- package/dist/tests/diagrams.test.d.ts +0 -1
- package/dist/tests/diagrams.test.js +0 -25
- package/dist/tests/graph.test.d.ts +0 -1
- package/dist/tests/graph.test.js +0 -33
- package/dist/tests/prebuilt.int.test.d.ts +0 -1
- package/dist/tests/prebuilt.int.test.js +0 -207
- package/dist/tests/prebuilt.test.d.ts +0 -1
- package/dist/tests/prebuilt.test.js +0 -427
- package/dist/tests/pregel.io.test.d.ts +0 -1
- package/dist/tests/pregel.io.test.js +0 -332
- package/dist/tests/pregel.read.test.d.ts +0 -1
- package/dist/tests/pregel.read.test.js +0 -109
- package/dist/tests/pregel.test.d.ts +0 -1
- package/dist/tests/pregel.test.js +0 -1882
- package/dist/tests/pregel.validate.test.d.ts +0 -1
- package/dist/tests/pregel.validate.test.js +0 -198
- package/dist/tests/pregel.write.test.d.ts +0 -1
- package/dist/tests/pregel.write.test.js +0 -44
- package/dist/tests/tracing.int.test.d.ts +0 -1
- package/dist/tests/tracing.int.test.js +0 -450
- package/dist/tests/tracing.test.d.ts +0 -1
- package/dist/tests/tracing.test.js +0 -332
- package/dist/tests/utils.d.ts +0 -53
- package/dist/tests/utils.js +0 -167
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@jest/globals";
|
|
2
|
-
import { PregelNode } from "../pregel/read.js";
|
|
3
|
-
import { GraphValidationError, validateGraph } from "../pregel/validate.js";
|
|
4
|
-
import { LastValue } from "../channels/last_value.js";
|
|
5
|
-
describe("validateGraph", () => {
|
|
6
|
-
it("should throw an error if a node is named __interrupt__", () => {
|
|
7
|
-
// set up test
|
|
8
|
-
const nodes = {
|
|
9
|
-
__interrupt__: new PregelNode({
|
|
10
|
-
channels: [""],
|
|
11
|
-
triggers: [],
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
const channels = {
|
|
15
|
-
"": new LastValue(),
|
|
16
|
-
};
|
|
17
|
-
// call method / assertions
|
|
18
|
-
expect(() => {
|
|
19
|
-
validateGraph({
|
|
20
|
-
nodes,
|
|
21
|
-
channels,
|
|
22
|
-
inputChannels: "",
|
|
23
|
-
outputChannels: "",
|
|
24
|
-
streamChannels: "",
|
|
25
|
-
interruptAfterNodes: [],
|
|
26
|
-
interruptBeforeNodes: [],
|
|
27
|
-
});
|
|
28
|
-
}).toThrow(GraphValidationError);
|
|
29
|
-
});
|
|
30
|
-
it("should throw an error if a node is not the correct type", () => {
|
|
31
|
-
// set up test
|
|
32
|
-
class PregelNodeSubclass extends PregelNode {
|
|
33
|
-
}
|
|
34
|
-
const nodes = {
|
|
35
|
-
channelName: new PregelNodeSubclass({
|
|
36
|
-
channels: [""],
|
|
37
|
-
triggers: [],
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
const channels = {
|
|
41
|
-
"": new LastValue(),
|
|
42
|
-
};
|
|
43
|
-
// call method / assertions
|
|
44
|
-
expect(() => {
|
|
45
|
-
validateGraph({
|
|
46
|
-
nodes,
|
|
47
|
-
channels,
|
|
48
|
-
inputChannels: "",
|
|
49
|
-
outputChannels: "",
|
|
50
|
-
streamChannels: "",
|
|
51
|
-
interruptAfterNodes: [],
|
|
52
|
-
interruptBeforeNodes: [],
|
|
53
|
-
});
|
|
54
|
-
}).toThrow(GraphValidationError);
|
|
55
|
-
});
|
|
56
|
-
it("should throw an error if input channel is not subscribed to by any node", () => {
|
|
57
|
-
// set up test
|
|
58
|
-
const nodes = {
|
|
59
|
-
channelName1: new PregelNode({
|
|
60
|
-
channels: [""],
|
|
61
|
-
triggers: ["channelName2"],
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
const channels = {
|
|
65
|
-
"": new LastValue(),
|
|
66
|
-
};
|
|
67
|
-
// call method / assertions
|
|
68
|
-
expect(() => {
|
|
69
|
-
validateGraph({
|
|
70
|
-
nodes,
|
|
71
|
-
channels,
|
|
72
|
-
// @ts-expect-error - testing invalid input
|
|
73
|
-
inputChannels: "channelName3",
|
|
74
|
-
outputChannels: "",
|
|
75
|
-
streamChannels: "",
|
|
76
|
-
interruptAfterNodes: [],
|
|
77
|
-
interruptBeforeNodes: [],
|
|
78
|
-
});
|
|
79
|
-
}).toThrow(GraphValidationError);
|
|
80
|
-
});
|
|
81
|
-
it("should throw an error if none of the input channels are subscribed to by any node", () => {
|
|
82
|
-
// set up test
|
|
83
|
-
const nodes = {
|
|
84
|
-
channelName1: new PregelNode({
|
|
85
|
-
channels: [""],
|
|
86
|
-
triggers: ["channelName2"],
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
const channels = {
|
|
90
|
-
"": new LastValue(),
|
|
91
|
-
};
|
|
92
|
-
// call method / assertions
|
|
93
|
-
expect(() => {
|
|
94
|
-
validateGraph({
|
|
95
|
-
nodes,
|
|
96
|
-
channels,
|
|
97
|
-
// @ts-expect-error - testing invalid input
|
|
98
|
-
inputChannels: ["channelName3", "channelName4", "channelName5"],
|
|
99
|
-
outputChannels: "",
|
|
100
|
-
streamChannels: "",
|
|
101
|
-
interruptAfterNodes: [],
|
|
102
|
-
interruptBeforeNodes: [],
|
|
103
|
-
});
|
|
104
|
-
}).toThrow(GraphValidationError);
|
|
105
|
-
});
|
|
106
|
-
it("should throw an error if 'interrupt after' nodes not in nodes map", () => {
|
|
107
|
-
// set up test
|
|
108
|
-
const nodes = {
|
|
109
|
-
channelName1: new PregelNode({
|
|
110
|
-
channels: [""],
|
|
111
|
-
triggers: ["channelName2"],
|
|
112
|
-
}),
|
|
113
|
-
};
|
|
114
|
-
const channels = {
|
|
115
|
-
"": new LastValue(),
|
|
116
|
-
};
|
|
117
|
-
// call method / assertions
|
|
118
|
-
expect(() => {
|
|
119
|
-
validateGraph({
|
|
120
|
-
nodes,
|
|
121
|
-
channels,
|
|
122
|
-
inputChannels: [""],
|
|
123
|
-
outputChannels: "",
|
|
124
|
-
streamChannels: "",
|
|
125
|
-
interruptAfterNodes: ["channelName3"],
|
|
126
|
-
interruptBeforeNodes: [],
|
|
127
|
-
});
|
|
128
|
-
}).toThrow(GraphValidationError);
|
|
129
|
-
});
|
|
130
|
-
it("should throw an error if 'interrupt after' nodes not in nodes map", () => {
|
|
131
|
-
// set up test
|
|
132
|
-
const nodes = {
|
|
133
|
-
channelName1: new PregelNode({
|
|
134
|
-
channels: [""],
|
|
135
|
-
triggers: ["channelName2"],
|
|
136
|
-
}),
|
|
137
|
-
};
|
|
138
|
-
const channels = {
|
|
139
|
-
"": new LastValue(),
|
|
140
|
-
};
|
|
141
|
-
// call method / assertions
|
|
142
|
-
expect(() => {
|
|
143
|
-
validateGraph({
|
|
144
|
-
nodes,
|
|
145
|
-
channels,
|
|
146
|
-
inputChannels: [""],
|
|
147
|
-
outputChannels: "",
|
|
148
|
-
streamChannels: "",
|
|
149
|
-
interruptAfterNodes: [],
|
|
150
|
-
interruptBeforeNodes: ["channelName3"],
|
|
151
|
-
});
|
|
152
|
-
}).toThrow(GraphValidationError);
|
|
153
|
-
});
|
|
154
|
-
it("should thrown on missing channels", () => {
|
|
155
|
-
// set up test
|
|
156
|
-
const nodes = {
|
|
157
|
-
channelName1: new PregelNode({
|
|
158
|
-
channels: [""],
|
|
159
|
-
triggers: ["channelName2"],
|
|
160
|
-
}),
|
|
161
|
-
};
|
|
162
|
-
const channels1 = {
|
|
163
|
-
"": new LastValue(),
|
|
164
|
-
channelName2: new LastValue(),
|
|
165
|
-
};
|
|
166
|
-
// call method / assertions
|
|
167
|
-
expect(() => validateGraph({
|
|
168
|
-
nodes,
|
|
169
|
-
channels: channels1,
|
|
170
|
-
inputChannels: "channelName2",
|
|
171
|
-
// @ts-expect-error - testing invalid input
|
|
172
|
-
outputChannels: "channelName3",
|
|
173
|
-
interruptAfterNodes: [],
|
|
174
|
-
interruptBeforeNodes: [],
|
|
175
|
-
})).toThrow(GraphValidationError);
|
|
176
|
-
// call method / assertions
|
|
177
|
-
expect(() => validateGraph({
|
|
178
|
-
nodes,
|
|
179
|
-
channels: channels1,
|
|
180
|
-
// @ts-expect-error - testing invalid input
|
|
181
|
-
inputChannels: "channelName3",
|
|
182
|
-
outputChannels: "channelName2",
|
|
183
|
-
interruptAfterNodes: [],
|
|
184
|
-
interruptBeforeNodes: [],
|
|
185
|
-
})).toThrow(GraphValidationError);
|
|
186
|
-
// call method / assertions
|
|
187
|
-
expect(() => validateGraph({
|
|
188
|
-
nodes,
|
|
189
|
-
channels: channels1,
|
|
190
|
-
inputChannels: "channelName2",
|
|
191
|
-
outputChannels: "",
|
|
192
|
-
// @ts-expect-error - testing invalid input
|
|
193
|
-
streamChannels: "channelName4",
|
|
194
|
-
interruptAfterNodes: [],
|
|
195
|
-
interruptBeforeNodes: [],
|
|
196
|
-
})).toThrow(GraphValidationError);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@jest/globals";
|
|
2
|
-
import { RunnablePassthrough } from "@langchain/core/runnables";
|
|
3
|
-
import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
|
|
4
|
-
describe("ChannelWrite", () => {
|
|
5
|
-
describe("_getWriteValues", () => {
|
|
6
|
-
it("should return the expect object", async () => {
|
|
7
|
-
// set up test
|
|
8
|
-
const channelWrite = new ChannelWrite([
|
|
9
|
-
{
|
|
10
|
-
channel: "someChannel1",
|
|
11
|
-
value: 1,
|
|
12
|
-
skipNone: false,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
channel: "someChannel2",
|
|
16
|
-
value: PASSTHROUGH,
|
|
17
|
-
skipNone: false,
|
|
18
|
-
mapper: new RunnablePassthrough(),
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
channel: "someChannel3",
|
|
22
|
-
value: null,
|
|
23
|
-
skipNone: true,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
channel: "someChannel4",
|
|
27
|
-
value: PASSTHROUGH,
|
|
28
|
-
skipNone: false,
|
|
29
|
-
},
|
|
30
|
-
]);
|
|
31
|
-
const input = 2;
|
|
32
|
-
const config = {};
|
|
33
|
-
// call method / assertions
|
|
34
|
-
const writeValues = await channelWrite._getWriteValues(input, config);
|
|
35
|
-
const expectedWriteValues = {
|
|
36
|
-
someChannel1: 1,
|
|
37
|
-
someChannel2: 2,
|
|
38
|
-
// someChannel3 should be filtered out
|
|
39
|
-
someChannel4: 2, // value is set to input value since PASSTHROUGH value was specified
|
|
40
|
-
};
|
|
41
|
-
expect(writeValues).toEqual(expectedWriteValues);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|