@langgraph-js/sdk 4.3.8 → 4.4.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 CHANGED
@@ -8,3 +8,4 @@ export * from "./TestKit.js";
8
8
  export * from "./artifacts/index.js";
9
9
  export * from "./client/index.js";
10
10
  export * from "./History.js";
11
+ export * from "./utils/index.js";
package/dist/index.js CHANGED
@@ -8,3 +8,4 @@ export * from "./TestKit.js";
8
8
  export * from "./artifacts/index.js";
9
9
  export * from "./client/index.js";
10
10
  export * from "./History.js";
11
+ export * from "./utils/index.js";
@@ -0,0 +1,5 @@
1
+ import { RenderMessage } from "../LangGraphClient.js";
2
+ /** 获取 AIMessage 中的 Thinking 文本 */
3
+ export declare const getThinkingContent: (message: RenderMessage) => any;
4
+ /** 获取 AIMessage 中的纯文本 */
5
+ export declare const getTextContent: (message: RenderMessage) => string;
@@ -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.8",
3
+ "version": "4.4.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",
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from "./TestKit.js";
8
8
  export * from "./artifacts/index.js";
9
9
  export * from "./client/index.js";
10
10
  export * from "./History.js";
11
+ export * from "./utils/index.js";
@@ -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
+ };