@langgraph-js/sdk 1.7.6 → 1.7.10
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/LICENSE +201 -201
- package/README.md +163 -163
- package/dist/LangGraphClient.js +1 -1
- package/dist/ToolManager.d.ts +1 -1
- package/dist/ToolManager.js +2 -1
- package/dist/tool/createTool.d.ts +4 -0
- package/dist/ui-store/createChatStore.js +0 -3
- package/package.json +1 -1
- package/src/LangGraphClient.ts +655 -655
- package/src/SpendTime.ts +60 -60
- package/src/ToolManager.ts +132 -131
- package/src/index.ts +5 -5
- package/src/tool/ToolUI.ts +55 -55
- package/src/tool/copilotkit-actions.ts +72 -72
- package/src/tool/createTool.ts +104 -102
- package/src/tool/index.ts +3 -3
- package/src/tool/utils.ts +158 -158
- package/src/ui-store/UnionStore.ts +29 -29
- package/src/ui-store/createChatStore.ts +295 -298
- package/src/ui-store/index.ts +2 -2
- package/src/ui-store/rafDebounce.ts +29 -29
- package/test/testResponse.json +5418 -5418
- package/tsconfig.json +112 -112
- package/.env +0 -0
- package/.turbo/turbo-build.log +0 -5
- package/dist/server/createState.d.ts +0 -13
- package/dist/server/createState.js +0 -20
- package/dist/server/feTools.d.ts +0 -16
- package/dist/server/feTools.js +0 -37
- package/dist/server/index.d.ts +0 -3
- package/dist/server/index.js +0 -3
- package/dist/server/interrupt/index.d.ts +0 -23
- package/dist/server/interrupt/index.js +0 -36
- package/dist/server/swarm/handoff.d.ts +0 -11
- package/dist/server/swarm/handoff.js +0 -84
- package/dist/server/swarm/keepState.d.ts +0 -6
- package/dist/server/swarm/keepState.js +0 -21
- package/dist/server/tools/index.d.ts +0 -1
- package/dist/server/tools/index.js +0 -1
- package/dist/server/tools/sequential-thinking.d.ts +0 -52
- package/dist/server/tools/sequential-thinking.js +0 -69
- package/dist/server/utils.d.ts +0 -3
- package/dist/server/utils.js +0 -24
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { tool } from "@langchain/core/tools";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
const schema = z.object({
|
|
4
|
-
thought: z.string().describe("Your current thinking step"),
|
|
5
|
-
nextThoughtNeeded: z.boolean().describe("Whether another thought step is needed"),
|
|
6
|
-
thoughtNumber: z.number().min(1).describe("Current thought number"),
|
|
7
|
-
totalThoughts: z.number().min(1).describe("Estimated total thoughts needed"),
|
|
8
|
-
isRevision: z.boolean().optional().describe("Whether this revises previous thinking"),
|
|
9
|
-
revisesThought: z.number().min(1).optional().describe("Which thought is being reconsidered"),
|
|
10
|
-
branchFromThought: z.number().min(1).optional().describe("Branching point thought number"),
|
|
11
|
-
branchId: z.string().optional().describe("Branch identifier"),
|
|
12
|
-
needsMoreThoughts: z.boolean().optional().describe("If more thoughts are needed"),
|
|
13
|
-
});
|
|
14
|
-
// 存储思考历史
|
|
15
|
-
const thoughtHistory = [];
|
|
16
|
-
const branches = {};
|
|
17
|
-
export const SequentialThinkingTool = tool(async (args) => {
|
|
18
|
-
try {
|
|
19
|
-
if (args.thoughtNumber > args.totalThoughts) {
|
|
20
|
-
args.totalThoughts = args.thoughtNumber;
|
|
21
|
-
}
|
|
22
|
-
thoughtHistory.push(args);
|
|
23
|
-
if (args.branchFromThought && args.branchId) {
|
|
24
|
-
if (!branches[args.branchId]) {
|
|
25
|
-
branches[args.branchId] = [];
|
|
26
|
-
}
|
|
27
|
-
branches[args.branchId].push(args);
|
|
28
|
-
}
|
|
29
|
-
return JSON.stringify({
|
|
30
|
-
thoughtNumber: args.thoughtNumber,
|
|
31
|
-
totalThoughts: args.totalThoughts,
|
|
32
|
-
nextThoughtNeeded: args.nextThoughtNeeded,
|
|
33
|
-
branches: Object.keys(branches),
|
|
34
|
-
thoughtHistoryLength: thoughtHistory.length,
|
|
35
|
-
}, null, 2);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
return JSON.stringify({
|
|
39
|
-
error: error instanceof Error ? error.message : String(error),
|
|
40
|
-
status: "failed",
|
|
41
|
-
}, null, 2);
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
name: "sequential-thinking",
|
|
45
|
-
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
|
|
46
|
-
This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
|
|
47
|
-
Each thought can build on, question, or revise previous insights as understanding deepens.
|
|
48
|
-
|
|
49
|
-
When to use this tool:
|
|
50
|
-
- Breaking down complex problems into steps
|
|
51
|
-
- Planning and design with room for revision
|
|
52
|
-
- Analysis that might need course correction
|
|
53
|
-
- Problems where the full scope might not be clear initially
|
|
54
|
-
- Problems that require a multi-step solution
|
|
55
|
-
- Tasks that need to maintain context over multiple steps
|
|
56
|
-
- Situations where irrelevant information needs to be filtered out
|
|
57
|
-
|
|
58
|
-
Key features:
|
|
59
|
-
- You can adjust total_thoughts up or down as you progress
|
|
60
|
-
- You can question or revise previous thoughts
|
|
61
|
-
- You can add more thoughts even after reaching what seemed like the end
|
|
62
|
-
- You can express uncertainty and explore alternative approaches
|
|
63
|
-
- Not every thought needs to build linearly - you can branch or backtrack
|
|
64
|
-
- Generates a solution hypothesis
|
|
65
|
-
- Verifies the hypothesis based on the Chain of Thought steps
|
|
66
|
-
- Repeats the process until satisfied
|
|
67
|
-
- Provides a correct answer`,
|
|
68
|
-
schema,
|
|
69
|
-
});
|
package/dist/server/utils.d.ts
DELETED
package/dist/server/utils.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isHumanMessage } from "@langchain/core/messages";
|
|
2
|
-
export const getTextMessageContent = (message) => {
|
|
3
|
-
if (typeof message.content === "string") {
|
|
4
|
-
return message.content;
|
|
5
|
-
}
|
|
6
|
-
else {
|
|
7
|
-
return message.content
|
|
8
|
-
.filter((i) => i.type === "text")
|
|
9
|
-
.map((i) => i.text)
|
|
10
|
-
.join("\n");
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export function getLastHumanMessage(messages) {
|
|
14
|
-
// 从后往前遍历消息列表
|
|
15
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
16
|
-
const message = messages[i];
|
|
17
|
-
// 检查消息是否是 HumanMessage 的实例
|
|
18
|
-
if (isHumanMessage(message)) {
|
|
19
|
-
return message;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// 如果没有找到 HumanMessage,则返回 undefined
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|