@langchain/langgraph 0.0.34 → 0.1.0-rc.0
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 +11 -15
- package/dist/channels/any_value.cjs +3 -1
- package/dist/channels/any_value.d.ts +1 -1
- package/dist/channels/any_value.js +3 -1
- package/dist/channels/base.cjs +8 -0
- package/dist/channels/base.d.ts +12 -1
- package/dist/channels/base.js +8 -0
- package/dist/channels/binop.cjs +2 -1
- package/dist/channels/binop.d.ts +1 -1
- package/dist/channels/binop.js +2 -1
- package/dist/channels/dynamic_barrier_value.cjs +30 -18
- package/dist/channels/dynamic_barrier_value.d.ts +2 -1
- package/dist/channels/dynamic_barrier_value.js +30 -18
- package/dist/channels/ephemeral_value.cjs +3 -1
- package/dist/channels/ephemeral_value.d.ts +1 -1
- package/dist/channels/ephemeral_value.js +3 -1
- package/dist/channels/last_value.cjs +3 -2
- package/dist/channels/last_value.d.ts +1 -1
- package/dist/channels/last_value.js +3 -2
- package/dist/channels/named_barrier_value.cjs +14 -6
- package/dist/channels/named_barrier_value.d.ts +2 -1
- package/dist/channels/named_barrier_value.js +15 -7
- package/dist/channels/topic.cjs +10 -11
- package/dist/channels/topic.d.ts +1 -1
- package/dist/channels/topic.js +10 -11
- package/dist/checkpoint/base.cjs +9 -0
- package/dist/checkpoint/base.d.ts +23 -18
- package/dist/checkpoint/base.js +9 -0
- package/dist/checkpoint/id.cjs +13 -1
- package/dist/checkpoint/id.d.ts +1 -0
- package/dist/checkpoint/id.js +12 -1
- package/dist/checkpoint/index.d.ts +2 -1
- package/dist/checkpoint/memory.cjs +152 -39
- package/dist/checkpoint/memory.d.ts +6 -3
- package/dist/checkpoint/memory.js +152 -39
- package/dist/checkpoint/serde/types.cjs +2 -0
- package/dist/checkpoint/serde/types.d.ts +40 -0
- package/dist/checkpoint/serde/types.js +1 -0
- package/dist/checkpoint/sqlite.cjs +127 -98
- package/dist/checkpoint/sqlite.d.ts +5 -3
- package/dist/checkpoint/sqlite.js +127 -98
- package/dist/checkpoint/types.cjs +2 -0
- package/dist/checkpoint/types.d.ts +28 -0
- package/dist/checkpoint/types.js +1 -0
- package/dist/constants.cjs +17 -1
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +16 -0
- package/dist/errors.cjs +21 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +18 -0
- package/dist/graph/graph.cjs +6 -3
- package/dist/graph/graph.d.ts +6 -2
- package/dist/graph/graph.js +7 -4
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/state.cjs +7 -7
- package/dist/graph/state.js +7 -7
- package/dist/pregel/algo.cjs +384 -0
- package/dist/pregel/algo.d.ts +32 -0
- package/dist/pregel/algo.js +374 -0
- package/dist/pregel/debug.cjs +158 -9
- package/dist/pregel/debug.d.ts +39 -2
- package/dist/pregel/debug.js +151 -7
- package/dist/pregel/index.cjs +217 -509
- package/dist/pregel/index.d.ts +29 -66
- package/dist/pregel/index.js +219 -506
- package/dist/pregel/io.cjs +2 -2
- package/dist/pregel/io.d.ts +5 -4
- package/dist/pregel/io.js +2 -2
- package/dist/pregel/loop.cjs +428 -0
- package/dist/pregel/loop.d.ts +84 -0
- package/dist/pregel/loop.js +421 -0
- package/dist/pregel/types.d.ts +53 -4
- package/dist/pregel/utils.cjs +33 -0
- package/dist/pregel/utils.d.ts +3 -0
- package/dist/pregel/utils.js +28 -0
- package/dist/pregel/write.cjs +3 -1
- package/dist/pregel/write.js +3 -1
- package/dist/utils.cjs +21 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +18 -0
- package/dist/web.d.ts +3 -2
- package/package.json +4 -2
package/dist/pregel/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
|
|
2
|
-
import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
|
|
3
|
-
import { IterableReadableStream } from "@langchain/core/utils/stream";
|
|
4
2
|
import { BaseChannel } from "../channels/base.js";
|
|
5
|
-
import { BaseCheckpointSaver,
|
|
3
|
+
import { BaseCheckpointSaver, CheckpointListOptions } from "../checkpoint/base.js";
|
|
6
4
|
import { PregelNode } from "./read.js";
|
|
7
5
|
import { ChannelWrite } from "./write.js";
|
|
8
|
-
import { All,
|
|
6
|
+
import { All, PregelInterface, PregelParams, StateSnapshot, StreamMode } from "./types.js";
|
|
7
|
+
import { StrRecord } from "./algo.js";
|
|
9
8
|
type WriteValue = Runnable | RunnableFunc<unknown, unknown> | unknown;
|
|
10
9
|
export declare class Channel {
|
|
11
10
|
static subscribeTo(channels: string, options?: {
|
|
@@ -17,51 +16,20 @@ export declare class Channel {
|
|
|
17
16
|
}): PregelNode;
|
|
18
17
|
static writeTo(channels: string[], kwargs?: Record<string, WriteValue>): ChannelWrite;
|
|
19
18
|
}
|
|
20
|
-
export type StreamMode = "values" | "updates";
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
20
|
+
* Config for executing the graph.
|
|
23
21
|
*/
|
|
24
|
-
type StrRecord<K extends string, T> = {
|
|
25
|
-
[P in K]: T;
|
|
26
|
-
};
|
|
27
|
-
export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>> {
|
|
28
|
-
nodes: Nn;
|
|
29
|
-
channels: Cc;
|
|
30
|
-
inputs: keyof Cc | Array<keyof Cc>;
|
|
31
|
-
outputs: keyof Cc | Array<keyof Cc>;
|
|
32
|
-
/**
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
autoValidate?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* @default "values"
|
|
38
|
-
*/
|
|
39
|
-
streamMode?: StreamMode;
|
|
40
|
-
streamChannels?: keyof Cc | Array<keyof Cc>;
|
|
41
|
-
/**
|
|
42
|
-
* @default []
|
|
43
|
-
*/
|
|
44
|
-
interruptAfter?: Array<keyof Nn> | All;
|
|
45
|
-
/**
|
|
46
|
-
* @default []
|
|
47
|
-
*/
|
|
48
|
-
interruptBefore?: Array<keyof Nn> | All;
|
|
49
|
-
/**
|
|
50
|
-
* @default undefined
|
|
51
|
-
*/
|
|
52
|
-
stepTimeout?: number;
|
|
53
|
-
/**
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
debug?: boolean;
|
|
57
|
-
checkpointer?: BaseCheckpointSaver;
|
|
58
|
-
}
|
|
59
22
|
export interface PregelOptions<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>> extends RunnableConfig {
|
|
60
|
-
|
|
23
|
+
/** The stream mode for the graph run. Default is ["values"]. */
|
|
24
|
+
streamMode?: StreamMode | StreamMode[];
|
|
61
25
|
inputKeys?: keyof Cc | Array<keyof Cc>;
|
|
26
|
+
/** The output keys to retrieve from the graph run. */
|
|
62
27
|
outputKeys?: keyof Cc | Array<keyof Cc>;
|
|
28
|
+
/** The nodes to interrupt the graph run before. */
|
|
63
29
|
interruptBefore?: All | Array<keyof Nn>;
|
|
30
|
+
/** The nodes to interrupt the graph run after. */
|
|
64
31
|
interruptAfter?: All | Array<keyof Nn>;
|
|
32
|
+
/** Enable debug mode for the graph run. */
|
|
65
33
|
debug?: boolean;
|
|
66
34
|
}
|
|
67
35
|
export type PregelInputType = any;
|
|
@@ -71,49 +39,44 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
71
39
|
lc_namespace: string[];
|
|
72
40
|
nodes: Nn;
|
|
73
41
|
channels: Cc;
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
inputChannels: keyof Cc | Array<keyof Cc>;
|
|
43
|
+
outputChannels: keyof Cc | Array<keyof Cc>;
|
|
76
44
|
autoValidate: boolean;
|
|
77
|
-
streamMode: StreamMode;
|
|
45
|
+
streamMode: StreamMode[];
|
|
78
46
|
streamChannels?: keyof Cc | Array<keyof Cc>;
|
|
79
47
|
interruptAfter?: Array<keyof Nn> | All;
|
|
80
48
|
interruptBefore?: Array<keyof Nn> | All;
|
|
81
49
|
stepTimeout?: number;
|
|
82
50
|
debug: boolean;
|
|
83
51
|
checkpointer?: BaseCheckpointSaver;
|
|
84
|
-
constructor(fields:
|
|
52
|
+
constructor(fields: PregelParams<Nn, Cc>);
|
|
85
53
|
validate(): this;
|
|
86
54
|
get streamChannelsList(): Array<keyof Cc>;
|
|
87
55
|
get streamChannelsAsIs(): keyof Cc | Array<keyof Cc>;
|
|
88
56
|
getState(config: RunnableConfig): Promise<StateSnapshot>;
|
|
89
|
-
getStateHistory(config: RunnableConfig,
|
|
57
|
+
getStateHistory(config: RunnableConfig, options?: CheckpointListOptions): AsyncIterableIterator<StateSnapshot>;
|
|
90
58
|
updateState(config: RunnableConfig, values: Record<string, unknown> | unknown, asNode?: keyof Nn): Promise<RunnableConfig>;
|
|
91
59
|
_defaults(config: PregelOptions<Nn, Cc>): [
|
|
92
60
|
boolean,
|
|
93
|
-
StreamMode,
|
|
61
|
+
StreamMode[],
|
|
94
62
|
// stream mode
|
|
95
|
-
|
|
63
|
+
string | string[],
|
|
96
64
|
// input keys
|
|
97
|
-
|
|
65
|
+
string | string[],
|
|
98
66
|
RunnableConfig,
|
|
99
67
|
// config without pregel keys
|
|
100
|
-
All |
|
|
68
|
+
All | string[],
|
|
101
69
|
// interrupt before
|
|
102
|
-
All |
|
|
70
|
+
All | string[],
|
|
71
|
+
// interrupt after
|
|
72
|
+
BaseCheckpointSaver | undefined
|
|
103
73
|
];
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
74
|
+
_streamIterator(input: PregelInputType, options?: Partial<PregelOptions<Nn, Cc>>): AsyncGenerator<PregelOutputType>;
|
|
75
|
+
/**
|
|
76
|
+
* Run the graph with a single input and config.
|
|
77
|
+
* @param input
|
|
78
|
+
* @param options
|
|
79
|
+
*/
|
|
80
|
+
invoke(input: PregelInputType, options?: Partial<PregelOptions<Nn, Cc>>): Promise<PregelOutputType>;
|
|
108
81
|
}
|
|
109
|
-
export declare function _shouldInterrupt<N extends PropertyKey, C extends PropertyKey>(checkpoint: ReadonlyCheckpoint, interruptNodes: All | Array<N>, snapshotChannels: Array<C>, tasks: Array<PregelExecutableTask<N, C>>): boolean;
|
|
110
|
-
export declare function _localRead<Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, channels: Cc, writes: Array<[keyof Cc, unknown]>, select: Array<keyof Cc> | keyof Cc, fresh?: boolean): Record<string, unknown> | unknown;
|
|
111
|
-
export declare function _localWrite(commit: (writes: [string, any][]) => void, processes: Record<string, PregelNode>, channels: Record<string, BaseChannel>, writes: [string, any][]): void;
|
|
112
|
-
export declare function _applyWrites<Cc extends Record<string, BaseChannel>>(checkpoint: Checkpoint, channels: Cc, pendingWrites: Array<[keyof Cc, unknown]>): void;
|
|
113
|
-
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, forExecution: false, extra: {
|
|
114
|
-
step: number;
|
|
115
|
-
}): [Checkpoint, Array<PregelTaskDescription>];
|
|
116
|
-
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, forExecution: true, extra: {
|
|
117
|
-
step: number;
|
|
118
|
-
}): [Checkpoint, Array<PregelExecutableTask<keyof Nn, keyof Cc>>];
|
|
119
82
|
export {};
|