@langchain/langgraph-cli 0.0.8 → 0.0.9
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/storage/importMap.mjs +55 -0
- package/dist/storage/persist.mjs +13 -3
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PromptTemplate, AIMessagePromptTemplate, ChatMessagePromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, ImagePromptTemplate, PipelinePromptTemplate, } from "@langchain/core/prompts";
|
|
2
|
+
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ChatMessage, ChatMessageChunk, FunctionMessage, FunctionMessageChunk, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, } from "@langchain/core/messages";
|
|
3
|
+
import { StringPromptValue } from "@langchain/core/prompt_values";
|
|
4
|
+
export const prompts__prompt = {
|
|
5
|
+
PromptTemplate,
|
|
6
|
+
};
|
|
7
|
+
export const schema__messages = {
|
|
8
|
+
AIMessage,
|
|
9
|
+
AIMessageChunk,
|
|
10
|
+
BaseMessage,
|
|
11
|
+
BaseMessageChunk,
|
|
12
|
+
ChatMessage,
|
|
13
|
+
ChatMessageChunk,
|
|
14
|
+
FunctionMessage,
|
|
15
|
+
FunctionMessageChunk,
|
|
16
|
+
HumanMessage,
|
|
17
|
+
HumanMessageChunk,
|
|
18
|
+
SystemMessage,
|
|
19
|
+
SystemMessageChunk,
|
|
20
|
+
ToolMessage,
|
|
21
|
+
ToolMessageChunk,
|
|
22
|
+
};
|
|
23
|
+
export const schema = {
|
|
24
|
+
AIMessage,
|
|
25
|
+
AIMessageChunk,
|
|
26
|
+
BaseMessage,
|
|
27
|
+
BaseMessageChunk,
|
|
28
|
+
ChatMessage,
|
|
29
|
+
ChatMessageChunk,
|
|
30
|
+
FunctionMessage,
|
|
31
|
+
FunctionMessageChunk,
|
|
32
|
+
HumanMessage,
|
|
33
|
+
HumanMessageChunk,
|
|
34
|
+
SystemMessage,
|
|
35
|
+
SystemMessageChunk,
|
|
36
|
+
ToolMessage,
|
|
37
|
+
ToolMessageChunk,
|
|
38
|
+
};
|
|
39
|
+
export const prompts__chat = {
|
|
40
|
+
AIMessagePromptTemplate,
|
|
41
|
+
ChatMessagePromptTemplate,
|
|
42
|
+
ChatPromptTemplate,
|
|
43
|
+
HumanMessagePromptTemplate,
|
|
44
|
+
MessagesPlaceholder,
|
|
45
|
+
SystemMessagePromptTemplate,
|
|
46
|
+
};
|
|
47
|
+
export const prompts__image = {
|
|
48
|
+
ImagePromptTemplate,
|
|
49
|
+
};
|
|
50
|
+
export const prompts__pipeline = {
|
|
51
|
+
PipelinePromptTemplate,
|
|
52
|
+
};
|
|
53
|
+
export const prompts__base = {
|
|
54
|
+
StringPromptValue,
|
|
55
|
+
};
|
package/dist/storage/persist.mjs
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as superjson from "superjson";
|
|
4
|
+
import * as importMap from "./importMap.mjs";
|
|
5
|
+
import { load } from "@langchain/core/load";
|
|
4
6
|
// Add custom transformers for Uint8Array
|
|
5
7
|
superjson.registerCustom({
|
|
6
8
|
isApplicable: (v) => v instanceof Uint8Array,
|
|
7
9
|
serialize: (v) => Buffer.from(v).toString("base64"),
|
|
8
10
|
deserialize: (v) => new Uint8Array(Buffer.from(v, "base64")),
|
|
9
11
|
}, "Uint8Array");
|
|
12
|
+
export function serialize(data) {
|
|
13
|
+
return superjson.stringify(data);
|
|
14
|
+
}
|
|
15
|
+
export async function deserialize(input) {
|
|
16
|
+
const result = await load(input, { importMap });
|
|
17
|
+
return superjson.deserialize(result);
|
|
18
|
+
}
|
|
10
19
|
export class FileSystemPersistence {
|
|
11
20
|
filepath = null;
|
|
12
21
|
data = null;
|
|
@@ -20,9 +29,10 @@ export class FileSystemPersistence {
|
|
|
20
29
|
async initialize(cwd) {
|
|
21
30
|
this.filepath = path.resolve(cwd, ".langgraph_api", `${this.name}`);
|
|
22
31
|
try {
|
|
23
|
-
this.data =
|
|
32
|
+
this.data = await deserialize(await fs.readFile(this.filepath, "utf-8"));
|
|
24
33
|
}
|
|
25
|
-
catch {
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error(error);
|
|
26
36
|
this.data = this.defaultSchema();
|
|
27
37
|
}
|
|
28
38
|
await fs
|
|
@@ -34,7 +44,7 @@ export class FileSystemPersistence {
|
|
|
34
44
|
if (this.data == null || this.filepath == null)
|
|
35
45
|
return;
|
|
36
46
|
clearTimeout(this.flushTimeout);
|
|
37
|
-
await fs.writeFile(this.filepath,
|
|
47
|
+
await fs.writeFile(this.filepath, serialize(this.data), "utf-8");
|
|
38
48
|
}
|
|
39
49
|
schedulePersist() {
|
|
40
50
|
clearTimeout(this.flushTimeout);
|