@assistant-ui/react-langgraph 0.6.7 → 0.6.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertLangChainMessages.d.ts","sourceRoot":"","sources":["../src/convertLangChainMessages.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"convertLangChainMessages.d.ts","sourceRoot":"","sources":["../src/convertLangChainMessages.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAiF3C,eAAO,MAAM,wBAAwB,EAAE,2BAA2B,CAAC,QAAQ,CACzE,gBAAgB,CA6DjB,CAAC"}
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
import {
|
|
5
5
|
parsePartialJsonObject
|
|
6
6
|
} from "assistant-stream/utils";
|
|
7
|
+
var warnedMessagePartTypes = /* @__PURE__ */ new Set();
|
|
8
|
+
var warnForUnknownMessagePartType = (type) => {
|
|
9
|
+
if (typeof process === "undefined" || process?.env?.["NODE_ENV"] !== "development")
|
|
10
|
+
return;
|
|
11
|
+
if (warnedMessagePartTypes.has(type)) return;
|
|
12
|
+
warnedMessagePartTypes.add(type);
|
|
13
|
+
console.warn(`Unknown message part type: ${type}`);
|
|
14
|
+
};
|
|
7
15
|
var contentToParts = (content) => {
|
|
8
16
|
if (typeof content === "string")
|
|
9
17
|
return [{ type: "text", text: content }];
|
|
@@ -27,10 +35,10 @@ var contentToParts = (content) => {
|
|
|
27
35
|
case "thinking":
|
|
28
36
|
return { type: "reasoning", text: part.thinking };
|
|
29
37
|
case "reasoning":
|
|
30
|
-
return
|
|
38
|
+
return {
|
|
31
39
|
type: "reasoning",
|
|
32
|
-
text
|
|
33
|
-
}
|
|
40
|
+
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
41
|
+
};
|
|
34
42
|
case "tool_use":
|
|
35
43
|
return null;
|
|
36
44
|
case "input_json_delta":
|
|
@@ -45,10 +53,11 @@ var contentToParts = (content) => {
|
|
|
45
53
|
};
|
|
46
54
|
default:
|
|
47
55
|
const _exhaustiveCheck = type;
|
|
48
|
-
|
|
56
|
+
warnForUnknownMessagePartType(_exhaustiveCheck);
|
|
57
|
+
return null;
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
|
-
).
|
|
60
|
+
).filter((a) => a !== null);
|
|
52
61
|
};
|
|
53
62
|
var convertLangChainMessages = (message) => {
|
|
54
63
|
switch (message.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/convertLangChainMessages.ts"],"sourcesContent":["\"use client\";\n\nimport {\n ThreadAssistantMessage,\n useExternalMessageConverter,\n} from \"@assistant-ui/react\";\nimport { LangChainMessage } from \"./types\";\nimport { ToolCallMessagePart } from \"@assistant-ui/react\";\nimport { ThreadUserMessage } from \"@assistant-ui/react\";\nimport {\n parsePartialJsonObject,\n ReadonlyJSONObject,\n} from \"assistant-stream/utils\";\n\nconst contentToParts = (content: LangChainMessage[\"content\"]) => {\n if (typeof content === \"string\")\n return [{ type: \"text\" as const, text: content }];\n return content\n .map(\n (\n part,\n ):\n | (ThreadUserMessage | ThreadAssistantMessage)[\"content\"][number]\n |
|
|
1
|
+
{"version":3,"sources":["../src/convertLangChainMessages.ts"],"sourcesContent":["\"use client\";\n\nimport {\n ThreadAssistantMessage,\n useExternalMessageConverter,\n} from \"@assistant-ui/react\";\nimport { LangChainMessage } from \"./types\";\nimport { ToolCallMessagePart } from \"@assistant-ui/react\";\nimport { ThreadUserMessage } from \"@assistant-ui/react\";\nimport {\n parsePartialJsonObject,\n ReadonlyJSONObject,\n} from \"assistant-stream/utils\";\n\nconst warnedMessagePartTypes = new Set<string>();\nconst warnForUnknownMessagePartType = (type: string) => {\n if (\n typeof process === \"undefined\" ||\n process?.env?.[\"NODE_ENV\"] !== \"development\"\n )\n return;\n if (warnedMessagePartTypes.has(type)) return;\n warnedMessagePartTypes.add(type);\n console.warn(`Unknown message part type: ${type}`);\n};\n\nconst contentToParts = (content: LangChainMessage[\"content\"]) => {\n if (typeof content === \"string\")\n return [{ type: \"text\" as const, text: content }];\n return content\n .map(\n (\n part,\n ):\n | (ThreadUserMessage | ThreadAssistantMessage)[\"content\"][number]\n | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n return { type: \"text\", text: part.text };\n case \"text_delta\":\n return { type: \"text\", text: part.text };\n case \"image_url\":\n if (typeof part.image_url === \"string\") {\n return { type: \"image\", image: part.image_url };\n } else {\n return {\n type: \"image\",\n image: part.image_url.url,\n };\n }\n case \"thinking\":\n return { type: \"reasoning\", text: part.thinking };\n\n case \"reasoning\":\n return {\n type: \"reasoning\",\n text: part.summary.map((s) => s.text).join(\"\\n\\n\\n\"),\n };\n\n case \"tool_use\":\n return null;\n case \"input_json_delta\":\n return null;\n\n case \"computer_call\":\n return {\n type: \"tool-call\",\n toolCallId: part.call_id,\n toolName: \"computer_call\",\n args: part.action as ReadonlyJSONObject,\n argsText: JSON.stringify(part.action),\n };\n\n default:\n const _exhaustiveCheck: never = type;\n warnForUnknownMessagePartType(_exhaustiveCheck);\n return null;\n\n // const _exhaustiveCheck: never = type;\n // throw new Error(`Unknown message part type: ${_exhaustiveCheck}`);\n }\n },\n )\n .filter((a) => a !== null);\n};\n\nexport const convertLangChainMessages: useExternalMessageConverter.Callback<\n LangChainMessage\n> = (message) => {\n switch (message.type) {\n case \"system\":\n return {\n role: \"system\",\n id: message.id,\n content: [{ type: \"text\", text: message.content }],\n };\n case \"human\":\n return {\n role: \"user\",\n id: message.id,\n content: contentToParts(message.content),\n };\n case \"ai\":\n const toolCallParts =\n message.tool_calls?.map((chunk): ToolCallMessagePart => {\n const argsText =\n chunk.partial_json ??\n message.tool_call_chunks?.find((c) => c.id === chunk.id)?.args ??\n JSON.stringify(chunk.args);\n\n return {\n type: \"tool-call\",\n toolCallId: chunk.id,\n toolName: chunk.name,\n args: argsText\n ? (parsePartialJsonObject(argsText) ?? {})\n : chunk.args,\n argsText: argsText ?? JSON.stringify(chunk.args),\n };\n }) ?? [];\n\n const normalizedContent =\n typeof message.content === \"string\"\n ? [{ type: \"text\" as const, text: message.content }]\n : message.content;\n\n const allContent = [\n message.additional_kwargs?.reasoning,\n ...normalizedContent,\n ...(message.additional_kwargs?.tool_outputs ?? []),\n ].filter((c) => c !== undefined);\n\n return {\n role: \"assistant\",\n id: message.id,\n content: [...contentToParts(allContent), ...toolCallParts],\n ...(message.status && { status: message.status }),\n };\n case \"tool\":\n return {\n role: \"tool\",\n toolName: message.name,\n toolCallId: message.tool_call_id,\n result: message.content,\n artifact: message.artifact,\n isError: message.status === \"error\",\n };\n }\n};\n"],"mappings":";;;AASA;AAAA,EACE;AAAA,OAEK;AAEP,IAAM,yBAAyB,oBAAI,IAAY;AAC/C,IAAM,gCAAgC,CAAC,SAAiB;AACtD,MACE,OAAO,YAAY,eACnB,SAAS,MAAM,UAAU,MAAM;AAE/B;AACF,MAAI,uBAAuB,IAAI,IAAI,EAAG;AACtC,yBAAuB,IAAI,IAAI;AAC/B,UAAQ,KAAK,8BAA8B,IAAI,EAAE;AACnD;AAEA,IAAM,iBAAiB,CAAC,YAAyC;AAC/D,MAAI,OAAO,YAAY;AACrB,WAAO,CAAC,EAAE,MAAM,QAAiB,MAAM,QAAQ,CAAC;AAClD,SAAO,QACJ;AAAA,IACC,CACE,SAGU;AACV,YAAM,OAAO,KAAK;AAClB,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,iBAAO,EAAE,MAAM,QAAQ,MAAM,KAAK,KAAK;AAAA,QACzC,KAAK;AACH,iBAAO,EAAE,MAAM,QAAQ,MAAM,KAAK,KAAK;AAAA,QACzC,KAAK;AACH,cAAI,OAAO,KA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,UAAU,MAAM,IAAI;AAE3B,eAAO;AAAA,UACL,MAAM;AAAA,UACN,YAAY,MAAM;AAAA,UAClB,UAAU,MAAM;AAAA,UAChB,MAAM,WACD,uBAAuB,QAAQ,KAAK,CAAC,IACtC,MAAM;AAAA,UACV,UAAU,YAAY,KAAK,UAAU,MAAM,IAAI;AAAA,QACjD;AAAA,MACF,CAAC,KAAK,CAAC;AAET,YAAM,oBACJ,OAAO,QAAQ,YAAY,WACvB,CAAC,EAAE,MAAM,QAAiB,MAAM,QAAQ,QAAQ,CAAC,IACjD,QAAQ;AAEd,YAAM,aAAa;AAAA,QACjB,QAAQ,mBAAmB;AAAA,QAC3B,GAAG;AAAA,QACH,GAAI,QAAQ,mBAAmB,gBAAgB,CAAC;AAAA,MAClD,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AAE/B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,IAAI,QAAQ;AAAA,QACZ,SAAS,CAAC,GAAG,eAAe,UAAU,GAAG,GAAG,aAAa;AAAA,QACzD,GAAI,QAAQ,UAAU,EAAE,QAAQ,QAAQ,OAAO;AAAA,MACjD;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,UAAU,QAAQ;AAAA,QAClB,YAAY,QAAQ;AAAA,QACpB,QAAQ,QAAQ;AAAA,QAChB,UAAU,QAAQ;AAAA,QAClB,SAAS,QAAQ,WAAW;AAAA,MAC9B;AAAA,EACJ;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-langgraph",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
],
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"assistant-stream": "^0.2.
|
|
21
|
+
"assistant-stream": "^0.2.26",
|
|
22
22
|
"uuid": "^11.1.0",
|
|
23
23
|
"zod": "^4.0.17"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@assistant-ui/react": "^0.11.
|
|
26
|
+
"@assistant-ui/react": "^0.11.8",
|
|
27
27
|
"@types/react": "*",
|
|
28
28
|
"react": "^18 || ^19 || ^19.0.0-rc"
|
|
29
29
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react": "19.1.1",
|
|
45
45
|
"tsx": "^4.20.4",
|
|
46
46
|
"vitest": "^3.2.4",
|
|
47
|
-
"@assistant-ui/react": "0.11.
|
|
47
|
+
"@assistant-ui/react": "0.11.8",
|
|
48
48
|
"@assistant-ui/x-buildutils": "0.0.1"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
@@ -12,6 +12,18 @@ import {
|
|
|
12
12
|
ReadonlyJSONObject,
|
|
13
13
|
} from "assistant-stream/utils";
|
|
14
14
|
|
|
15
|
+
const warnedMessagePartTypes = new Set<string>();
|
|
16
|
+
const warnForUnknownMessagePartType = (type: string) => {
|
|
17
|
+
if (
|
|
18
|
+
typeof process === "undefined" ||
|
|
19
|
+
process?.env?.["NODE_ENV"] !== "development"
|
|
20
|
+
)
|
|
21
|
+
return;
|
|
22
|
+
if (warnedMessagePartTypes.has(type)) return;
|
|
23
|
+
warnedMessagePartTypes.add(type);
|
|
24
|
+
console.warn(`Unknown message part type: ${type}`);
|
|
25
|
+
};
|
|
26
|
+
|
|
15
27
|
const contentToParts = (content: LangChainMessage["content"]) => {
|
|
16
28
|
if (typeof content === "string")
|
|
17
29
|
return [{ type: "text" as const, text: content }];
|
|
@@ -21,7 +33,6 @@ const contentToParts = (content: LangChainMessage["content"]) => {
|
|
|
21
33
|
part,
|
|
22
34
|
):
|
|
23
35
|
| (ThreadUserMessage | ThreadAssistantMessage)["content"][number]
|
|
24
|
-
| (ThreadUserMessage | ThreadAssistantMessage)["content"][number][]
|
|
25
36
|
| null => {
|
|
26
37
|
const type = part.type;
|
|
27
38
|
switch (type) {
|
|
@@ -42,12 +53,10 @@ const contentToParts = (content: LangChainMessage["content"]) => {
|
|
|
42
53
|
return { type: "reasoning", text: part.thinking };
|
|
43
54
|
|
|
44
55
|
case "reasoning":
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
.map((
|
|
48
|
-
|
|
49
|
-
text,
|
|
50
|
-
}));
|
|
56
|
+
return {
|
|
57
|
+
type: "reasoning",
|
|
58
|
+
text: part.summary.map((s) => s.text).join("\n\n\n"),
|
|
59
|
+
};
|
|
51
60
|
|
|
52
61
|
case "tool_use":
|
|
53
62
|
return null;
|
|
@@ -65,11 +74,14 @@ const contentToParts = (content: LangChainMessage["content"]) => {
|
|
|
65
74
|
|
|
66
75
|
default:
|
|
67
76
|
const _exhaustiveCheck: never = type;
|
|
68
|
-
|
|
77
|
+
warnForUnknownMessagePartType(_exhaustiveCheck);
|
|
78
|
+
return null;
|
|
79
|
+
|
|
80
|
+
// const _exhaustiveCheck: never = type;
|
|
81
|
+
// throw new Error(`Unknown message part type: ${_exhaustiveCheck}`);
|
|
69
82
|
}
|
|
70
83
|
},
|
|
71
84
|
)
|
|
72
|
-
.flat()
|
|
73
85
|
.filter((a) => a !== null);
|
|
74
86
|
};
|
|
75
87
|
|