-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebug.js
More file actions
40 lines (33 loc) · 976 Bytes
/
Copy pathdebug.js
File metadata and controls
40 lines (33 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { StateGraph, START, END } = require('@langchain/langgraph');
// Debug function that logs the structure of state
function debugState({ state }) {
console.log('State structure:', JSON.stringify(state, null, 2));
return {};
}
// Create a simple StateGraph for debugging
const builder = new StateGraph({
channels: {
research_topic: { value: "test query" },
search_query: { value: "" }
}
});
// Add a debug node
builder.addNode("debug", debugState);
builder.addEdge(START, "debug");
builder.addEdge("debug", END);
const graph = builder.compile();
// Run the graph
async function main() {
try {
const initialState = {
research_topic: "test query",
search_query: ""
};
console.log("Initial state:", JSON.stringify(initialState, null, 2));
const result = await graph.invoke(initialState);
console.log("Result:", JSON.stringify(result, null, 2));
} catch (error) {
console.error("Error:", error);
}
}
main();