add initial testing
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { task, entrypoint } from "@langchain/langgraph";
|
||||
import { BaseMessage, SystemMessage } from "@langchain/core/messages";
|
||||
import { ChatOpenAI } from "@langchain/openai"
|
||||
import { arithmeticTools } from "../tools/arithmetic";
|
||||
|
||||
const model = new ChatOpenAI({
|
||||
model: "gpt-5-mini"
|
||||
});
|
||||
|
||||
const modelWithTools = model.bindTools(arithmeticTools);
|
||||
|
||||
export const modelNode = task({ name: "callLlm" }, async (messages: BaseMessage[]) => {
|
||||
|
||||
|
||||
return modelWithTools.invoke([
|
||||
new SystemMessage(
|
||||
"You are a helpful assistant tasked with performing arithmetic on a set of inputs."
|
||||
),
|
||||
...messages,
|
||||
]);
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { ToolCall } from "@langchain/core/messages/tool";
|
||||
import { task } from "@langchain/langgraph";
|
||||
import { arithmeticToolsByName } from "../tools/arithmetic";
|
||||
|
||||
export const toolNode = task({ name: "callTool" }, async (toolCall: ToolCall) => {
|
||||
const tool = arithmeticToolsByName[toolCall.name];
|
||||
return tool.invoke(toolCall);
|
||||
});
|
||||
Reference in New Issue
Block a user