@langchain/langgraph 0.2.36 → 0.2.38
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/constants.cjs +31 -2
- package/dist/constants.d.ts +17 -2
- package/dist/constants.js +31 -2
- package/dist/pregel/messages.cjs +10 -8
- package/dist/pregel/messages.js +10 -8
- package/dist/pregel/remote.cjs +14 -3
- package/dist/pregel/remote.js +15 -4
- package/package.json +2 -2
package/dist/constants.cjs
CHANGED
|
@@ -117,6 +117,12 @@ class Send {
|
|
|
117
117
|
value: "Send"
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
+
toJSON() {
|
|
121
|
+
return {
|
|
122
|
+
node: this.node,
|
|
123
|
+
args: this.args,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
120
126
|
}
|
|
121
127
|
exports.Send = Send;
|
|
122
128
|
function _isSend(x) {
|
|
@@ -206,12 +212,11 @@ class Command {
|
|
|
206
212
|
writable: true,
|
|
207
213
|
value: void 0
|
|
208
214
|
});
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
210
215
|
Object.defineProperty(this, "update", {
|
|
211
216
|
enumerable: true,
|
|
212
217
|
configurable: true,
|
|
213
218
|
writable: true,
|
|
214
|
-
value:
|
|
219
|
+
value: void 0
|
|
215
220
|
});
|
|
216
221
|
Object.defineProperty(this, "resume", {
|
|
217
222
|
enumerable: true,
|
|
@@ -246,6 +251,30 @@ class Command {
|
|
|
246
251
|
return [["__root__", this.update]];
|
|
247
252
|
}
|
|
248
253
|
}
|
|
254
|
+
toJSON() {
|
|
255
|
+
let serializedGoto;
|
|
256
|
+
if (typeof this.goto === "string") {
|
|
257
|
+
serializedGoto = this.goto;
|
|
258
|
+
}
|
|
259
|
+
else if (_isSend(this.goto)) {
|
|
260
|
+
serializedGoto = this.goto.toJSON();
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
serializedGoto = this.goto.map((innerGoto) => {
|
|
264
|
+
if (typeof innerGoto === "string") {
|
|
265
|
+
return innerGoto;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
return innerGoto.toJSON();
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
update: this.update,
|
|
274
|
+
resume: this.resume,
|
|
275
|
+
goto: serializedGoto,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
249
278
|
}
|
|
250
279
|
exports.Command = Command;
|
|
251
280
|
Object.defineProperty(Command, "PARENT", {
|
package/dist/constants.d.ts
CHANGED
|
@@ -83,6 +83,10 @@ export declare class Send implements SendInterface {
|
|
|
83
83
|
args: any;
|
|
84
84
|
lg_name: string;
|
|
85
85
|
constructor(node: string, args: any);
|
|
86
|
+
toJSON(): {
|
|
87
|
+
node: string;
|
|
88
|
+
args: any;
|
|
89
|
+
};
|
|
86
90
|
}
|
|
87
91
|
export declare function _isSend(x: unknown): x is Send;
|
|
88
92
|
export type Interrupt = {
|
|
@@ -105,7 +109,7 @@ export type CommandParams<R> = {
|
|
|
105
109
|
/**
|
|
106
110
|
* Update to apply to the graph's state.
|
|
107
111
|
*/
|
|
108
|
-
update?: Record<string,
|
|
112
|
+
update?: Record<string, unknown> | [string, unknown][];
|
|
109
113
|
/**
|
|
110
114
|
* Can be one of the following:
|
|
111
115
|
* - name of the node to navigate to next (any node that belongs to the specified `graph`)
|
|
@@ -181,11 +185,22 @@ export declare class Command<R = unknown> {
|
|
|
181
185
|
lg_name: string;
|
|
182
186
|
lc_direct_tool_output: boolean;
|
|
183
187
|
graph?: string;
|
|
184
|
-
update?: Record<string,
|
|
188
|
+
update?: Record<string, unknown> | [string, unknown][];
|
|
185
189
|
resume?: R;
|
|
186
190
|
goto: string | Send | (string | Send)[];
|
|
187
191
|
static PARENT: string;
|
|
188
192
|
constructor(args: CommandParams<R>);
|
|
189
193
|
_updateAsTuples(): [string, unknown][];
|
|
194
|
+
toJSON(): {
|
|
195
|
+
update: Record<string, unknown> | [string, unknown][] | undefined;
|
|
196
|
+
resume: R | undefined;
|
|
197
|
+
goto: string | {
|
|
198
|
+
node: string;
|
|
199
|
+
args: any;
|
|
200
|
+
} | (string | {
|
|
201
|
+
node: string;
|
|
202
|
+
args: any;
|
|
203
|
+
})[];
|
|
204
|
+
};
|
|
190
205
|
}
|
|
191
206
|
export declare function isCommand(x: unknown): x is Command;
|
package/dist/constants.js
CHANGED
|
@@ -113,6 +113,12 @@ export class Send {
|
|
|
113
113
|
value: "Send"
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
+
toJSON() {
|
|
117
|
+
return {
|
|
118
|
+
node: this.node,
|
|
119
|
+
args: this.args,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
116
122
|
}
|
|
117
123
|
export function _isSend(x) {
|
|
118
124
|
const operation = x;
|
|
@@ -200,12 +206,11 @@ export class Command {
|
|
|
200
206
|
writable: true,
|
|
201
207
|
value: void 0
|
|
202
208
|
});
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
209
|
Object.defineProperty(this, "update", {
|
|
205
210
|
enumerable: true,
|
|
206
211
|
configurable: true,
|
|
207
212
|
writable: true,
|
|
208
|
-
value:
|
|
213
|
+
value: void 0
|
|
209
214
|
});
|
|
210
215
|
Object.defineProperty(this, "resume", {
|
|
211
216
|
enumerable: true,
|
|
@@ -240,6 +245,30 @@ export class Command {
|
|
|
240
245
|
return [["__root__", this.update]];
|
|
241
246
|
}
|
|
242
247
|
}
|
|
248
|
+
toJSON() {
|
|
249
|
+
let serializedGoto;
|
|
250
|
+
if (typeof this.goto === "string") {
|
|
251
|
+
serializedGoto = this.goto;
|
|
252
|
+
}
|
|
253
|
+
else if (_isSend(this.goto)) {
|
|
254
|
+
serializedGoto = this.goto.toJSON();
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
serializedGoto = this.goto.map((innerGoto) => {
|
|
258
|
+
if (typeof innerGoto === "string") {
|
|
259
|
+
return innerGoto;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return innerGoto.toJSON();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
update: this.update,
|
|
268
|
+
resume: this.resume,
|
|
269
|
+
goto: serializedGoto,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
243
272
|
}
|
|
244
273
|
Object.defineProperty(Command, "PARENT", {
|
|
245
274
|
enumerable: true,
|
package/dist/pregel/messages.cjs
CHANGED
|
@@ -74,7 +74,7 @@ class StreamMessagesHandler extends base_1.BaseCallbackHandler {
|
|
|
74
74
|
handleChatModelStart(_llm, _messages, runId, _parentRunId, _extraParams, tags, metadata, name) {
|
|
75
75
|
if (metadata &&
|
|
76
76
|
// Include legacy LangGraph SDK tag
|
|
77
|
-
(!tags || !
|
|
77
|
+
(!tags || (!tags.includes(constants_js_1.TAG_NOSTREAM) && !tags.includes("nostream")))) {
|
|
78
78
|
this.metadatas[runId] = [
|
|
79
79
|
metadata.langgraph_checkpoint_ns.split("|"),
|
|
80
80
|
{ tags, name, ...metadata },
|
|
@@ -84,13 +84,15 @@ class StreamMessagesHandler extends base_1.BaseCallbackHandler {
|
|
|
84
84
|
handleLLMNewToken(token, _idx, runId, _parentRunId, _tags, fields) {
|
|
85
85
|
const chunk = fields?.chunk;
|
|
86
86
|
this.emittedChatModelRunIds[runId] = true;
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
if (this.metadatas[runId] !== undefined) {
|
|
88
|
+
if (isChatGenerationChunk(chunk)) {
|
|
89
|
+
this._emit(this.metadatas[runId], chunk.message);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this._emit(this.metadatas[runId], new messages_1.AIMessageChunk({
|
|
93
|
+
content: token,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
handleLLMEnd(output, runId) {
|
package/dist/pregel/messages.js
CHANGED
|
@@ -71,7 +71,7 @@ export class StreamMessagesHandler extends BaseCallbackHandler {
|
|
|
71
71
|
handleChatModelStart(_llm, _messages, runId, _parentRunId, _extraParams, tags, metadata, name) {
|
|
72
72
|
if (metadata &&
|
|
73
73
|
// Include legacy LangGraph SDK tag
|
|
74
|
-
(!tags || !
|
|
74
|
+
(!tags || (!tags.includes(TAG_NOSTREAM) && !tags.includes("nostream")))) {
|
|
75
75
|
this.metadatas[runId] = [
|
|
76
76
|
metadata.langgraph_checkpoint_ns.split("|"),
|
|
77
77
|
{ tags, name, ...metadata },
|
|
@@ -81,13 +81,15 @@ export class StreamMessagesHandler extends BaseCallbackHandler {
|
|
|
81
81
|
handleLLMNewToken(token, _idx, runId, _parentRunId, _tags, fields) {
|
|
82
82
|
const chunk = fields?.chunk;
|
|
83
83
|
this.emittedChatModelRunIds[runId] = true;
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
if (this.metadatas[runId] !== undefined) {
|
|
85
|
+
if (isChatGenerationChunk(chunk)) {
|
|
86
|
+
this._emit(this.metadatas[runId], chunk.message);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this._emit(this.metadatas[runId], new AIMessageChunk({
|
|
90
|
+
content: token,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
handleLLMEnd(output, runId) {
|
package/dist/pregel/remote.cjs
CHANGED
|
@@ -295,8 +295,8 @@ class RemoteGraph extends runnables_1.Runnable {
|
|
|
295
295
|
const sanitizedConfig = this._sanitizeConfig(mergedConfig);
|
|
296
296
|
const streamProtocolInstance = options?.configurable?.[constants_js_1.CONFIG_KEY_STREAM];
|
|
297
297
|
const streamSubgraphs = options?.subgraphs ?? streamProtocolInstance !== undefined;
|
|
298
|
-
const interruptBefore =
|
|
299
|
-
const interruptAfter =
|
|
298
|
+
const interruptBefore = options?.interruptBefore ?? this.interruptBefore;
|
|
299
|
+
const interruptAfter = options?.interruptAfter ?? this.interruptAfter;
|
|
300
300
|
const { updatedStreamModes, reqSingle, reqUpdates } = getStreamModes(options?.streamMode);
|
|
301
301
|
const extendedStreamModes = [
|
|
302
302
|
...new Set([
|
|
@@ -304,8 +304,19 @@ class RemoteGraph extends runnables_1.Runnable {
|
|
|
304
304
|
...(streamProtocolInstance?.modes ?? new Set()),
|
|
305
305
|
]),
|
|
306
306
|
];
|
|
307
|
+
let command;
|
|
308
|
+
let serializedInput;
|
|
309
|
+
if ((0, constants_js_1.isCommand)(input)) {
|
|
310
|
+
// TODO: Remove cast when SDK type fix gets merged
|
|
311
|
+
command = input.toJSON();
|
|
312
|
+
serializedInput = undefined;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
serializedInput = _serializeInputs(input);
|
|
316
|
+
}
|
|
307
317
|
for await (const chunk of this.client.runs.stream(sanitizedConfig.configurable.thread_id, this.graphId, {
|
|
308
|
-
|
|
318
|
+
command,
|
|
319
|
+
input: serializedInput,
|
|
309
320
|
config: sanitizedConfig,
|
|
310
321
|
streamMode: extendedStreamModes,
|
|
311
322
|
interruptBefore: interruptBefore,
|
package/dist/pregel/remote.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Graph as DrawableGraph, } from "@langchain/core/runnables/graph";
|
|
|
3
3
|
import { mergeConfigs, Runnable, } from "@langchain/core/runnables";
|
|
4
4
|
import { isBaseMessage } from "@langchain/core/messages";
|
|
5
5
|
import { GraphInterrupt, RemoteException, } from "../web.js";
|
|
6
|
-
import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_STREAM, INTERRUPT, } from "../constants.js";
|
|
6
|
+
import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_STREAM, INTERRUPT, isCommand, } from "../constants.js";
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
const _serializeInputs = (obj) => {
|
|
9
9
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -292,8 +292,8 @@ export class RemoteGraph extends Runnable {
|
|
|
292
292
|
const sanitizedConfig = this._sanitizeConfig(mergedConfig);
|
|
293
293
|
const streamProtocolInstance = options?.configurable?.[CONFIG_KEY_STREAM];
|
|
294
294
|
const streamSubgraphs = options?.subgraphs ?? streamProtocolInstance !== undefined;
|
|
295
|
-
const interruptBefore =
|
|
296
|
-
const interruptAfter =
|
|
295
|
+
const interruptBefore = options?.interruptBefore ?? this.interruptBefore;
|
|
296
|
+
const interruptAfter = options?.interruptAfter ?? this.interruptAfter;
|
|
297
297
|
const { updatedStreamModes, reqSingle, reqUpdates } = getStreamModes(options?.streamMode);
|
|
298
298
|
const extendedStreamModes = [
|
|
299
299
|
...new Set([
|
|
@@ -301,8 +301,19 @@ export class RemoteGraph extends Runnable {
|
|
|
301
301
|
...(streamProtocolInstance?.modes ?? new Set()),
|
|
302
302
|
]),
|
|
303
303
|
];
|
|
304
|
+
let command;
|
|
305
|
+
let serializedInput;
|
|
306
|
+
if (isCommand(input)) {
|
|
307
|
+
// TODO: Remove cast when SDK type fix gets merged
|
|
308
|
+
command = input.toJSON();
|
|
309
|
+
serializedInput = undefined;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
serializedInput = _serializeInputs(input);
|
|
313
|
+
}
|
|
304
314
|
for await (const chunk of this.client.runs.stream(sanitizedConfig.configurable.thread_id, this.graphId, {
|
|
305
|
-
|
|
315
|
+
command,
|
|
316
|
+
input: serializedInput,
|
|
306
317
|
config: sanitizedConfig,
|
|
307
318
|
streamMode: extendedStreamModes,
|
|
308
319
|
interruptBefore: interruptBefore,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@langchain/langgraph-checkpoint": "~0.0.13",
|
|
35
|
-
"@langchain/langgraph-sdk": "~0.0.
|
|
35
|
+
"@langchain/langgraph-sdk": "~0.0.32",
|
|
36
36
|
"uuid": "^10.0.0",
|
|
37
37
|
"zod": "^3.23.8"
|
|
38
38
|
},
|