@langgraph-js/sdk 4.3.7 → 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 +1 -0
- package/dist/index.js +1 -0
- package/dist/ui-store/createChatStore.js +3 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +16 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/ui-store/createChatStore.ts +2 -0
- package/src/utils/index.ts +19 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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
package/src/index.ts
CHANGED
|
@@ -154,6 +154,8 @@ export const createChatStore = (initClientName: string, config: Partial<LangGrap
|
|
|
154
154
|
const syncedSessions = sessions.get();
|
|
155
155
|
// 自动激活最近的历史会话
|
|
156
156
|
await activateSession(syncedSessions[0].sessionId);
|
|
157
|
+
} else {
|
|
158
|
+
await createNewSession();
|
|
157
159
|
}
|
|
158
160
|
} else {
|
|
159
161
|
// 创建新会话
|
|
@@ -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
|
+
};
|