@langgraph-js/sdk 4.3.8 → 4.5.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tool/ToolUI.js +2 -2
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +16 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/tool/ToolUI.ts +2 -2
- package/src/utils/index.ts +19 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/tool/ToolUI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getMessageContent } from "../ui-store/createChatStore.js";
|
|
2
|
-
import {
|
|
2
|
+
import { parse, Allow } from "partial-json";
|
|
3
3
|
import { createActionRequestID } from "../humanInTheLoop.js";
|
|
4
4
|
export class ToolRenderData {
|
|
5
5
|
message;
|
|
@@ -86,7 +86,7 @@ export class ToolRenderData {
|
|
|
86
86
|
}
|
|
87
87
|
getInputRepaired() {
|
|
88
88
|
try {
|
|
89
|
-
return
|
|
89
|
+
return parse(this.message.tool_input || "", Allow.ALL);
|
|
90
90
|
}
|
|
91
91
|
catch (e) {
|
|
92
92
|
return {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 获取 AIMessage 中的 Thinking 文本 */
|
|
2
|
+
export const getThinkingContent = (message) => {
|
|
3
|
+
/** @ts-ignore 解决 langgraph sdk 没有类型的问题 */
|
|
4
|
+
return message.additional_kwargs?.reasoning_content || (Array.isArray(message.content) && message.content.find((i) => i.type === "thinking")?.thinking);
|
|
5
|
+
};
|
|
6
|
+
/** 获取 AIMessage 中的纯文本 */
|
|
7
|
+
export const getTextContent = (message) => {
|
|
8
|
+
return typeof message.content === "string"
|
|
9
|
+
? message.content
|
|
10
|
+
: message.content
|
|
11
|
+
?.filter((i) => {
|
|
12
|
+
return i.type === "text";
|
|
13
|
+
})
|
|
14
|
+
.map((i) => i.text)
|
|
15
|
+
.join("");
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langgraph-js/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"camelcase-keys": "^10.0.1",
|
|
54
54
|
"change-case": "^5.4.4",
|
|
55
55
|
"eventemitter3": "^5.0.1",
|
|
56
|
-
"jsonrepair": "^3.12.0",
|
|
57
56
|
"nanostores": "^1.0.1",
|
|
57
|
+
"partial-json": "^0.1.7",
|
|
58
58
|
"ts-debounce": "^4.0.0",
|
|
59
59
|
"zod": "^4",
|
|
60
60
|
"zod-to-json-schema": "^3.24.5"
|
package/src/index.ts
CHANGED
package/src/tool/ToolUI.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RenderMessage } from "../LangGraphClient.js";
|
|
|
2
2
|
|
|
3
3
|
import { LangGraphClient } from "../LangGraphClient.js";
|
|
4
4
|
import { getMessageContent } from "../ui-store/createChatStore.js";
|
|
5
|
-
import {
|
|
5
|
+
import { parse, Allow } from "partial-json";
|
|
6
6
|
import { createActionRequestID, HumanInTheLoopDecision, InterruptResponse } from "../humanInTheLoop.js";
|
|
7
7
|
|
|
8
8
|
export type DeepPartial<T> = {
|
|
@@ -90,7 +90,7 @@ export class ToolRenderData<I, D> {
|
|
|
90
90
|
}
|
|
91
91
|
getInputRepaired(): DeepPartial<I> {
|
|
92
92
|
try {
|
|
93
|
-
return
|
|
93
|
+
return parse(this.message.tool_input || "", Allow.ALL);
|
|
94
94
|
} catch (e) {
|
|
95
95
|
return {};
|
|
96
96
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RenderMessage } from "../LangGraphClient.js";
|
|
2
|
+
|
|
3
|
+
/** 获取 AIMessage 中的 Thinking 文本 */
|
|
4
|
+
export const getThinkingContent = (message: RenderMessage) => {
|
|
5
|
+
/** @ts-ignore 解决 langgraph sdk 没有类型的问题 */
|
|
6
|
+
return message.additional_kwargs?.reasoning_content || (Array.isArray(message.content) && message.content.find((i) => i.type === "thinking")?.thinking);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** 获取 AIMessage 中的纯文本 */
|
|
10
|
+
export const getTextContent = (message: RenderMessage) => {
|
|
11
|
+
return typeof message.content === "string"
|
|
12
|
+
? message.content
|
|
13
|
+
: message.content
|
|
14
|
+
?.filter((i) => {
|
|
15
|
+
return i.type === "text";
|
|
16
|
+
})
|
|
17
|
+
.map((i) => i.text)
|
|
18
|
+
.join("");
|
|
19
|
+
};
|