start adding dummy nodes

This commit is contained in:
William Jeynes
2026-01-28 21:26:34 +00:00
parent a3201d17a2
commit c6416622e4
14 changed files with 188 additions and 61 deletions
+23 -6
View File
@@ -1,8 +1,25 @@
import type { ToolCall } from "@langchain/core/messages/tool";
import { task } from "@langchain/langgraph";
import { AIMessage, ToolMessage } from "@langchain/core/messages";
import { GraphNode } from "@langchain/langgraph";
import { MessagesState } from "../state";
import { arithmeticToolsByName } from "../tools/arithmetic";
export const toolNode = task({ name: "callTool" }, async (toolCall: ToolCall) => {
const tool = arithmeticToolsByName[toolCall.name];
return tool.invoke(toolCall);
});
export const toolNode: GraphNode<typeof MessagesState> = async (state) => {
const lastMessage = state.messages.at(-1);
//STARTTEMP
return {messages: [new AIMessage("yeman")]}
//ENDTEMP
if (lastMessage == null || !AIMessage.isInstance(lastMessage)) {
return { messages: [] };
}
const result: ToolMessage[] = [];
for (const toolCall of lastMessage.tool_calls ?? []) {
const tool = arithmeticToolsByName[toolCall.name];
const observation = await tool.invoke(toolCall);
result.push(observation);
}
return { messages: result };
};