add initial testing
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import * as z from "zod";
|
||||
|
||||
|
||||
// Define tools
|
||||
const add = tool(({ a, b }) => a + b, {
|
||||
name: "add",
|
||||
description: "Add two numbers",
|
||||
schema: z.object({
|
||||
a: z.number().describe("First number"),
|
||||
b: z.number().describe("Second number"),
|
||||
}),
|
||||
});
|
||||
|
||||
const multiply = tool(({ a, b }) => a * b, {
|
||||
name: "multiply",
|
||||
description: "Multiply two numbers",
|
||||
schema: z.object({
|
||||
a: z.number().describe("First number"),
|
||||
b: z.number().describe("Second number"),
|
||||
}),
|
||||
});
|
||||
|
||||
const divide = tool(({ a, b }) => a / b, {
|
||||
name: "divide",
|
||||
description: "Divide two numbers",
|
||||
schema: z.object({
|
||||
a: z.number().describe("First number"),
|
||||
b: z.number().describe("Second number"),
|
||||
}),
|
||||
});
|
||||
|
||||
// Augment the LLM with tools
|
||||
export const arithmeticToolsByName = {
|
||||
[add.name]: add,
|
||||
[multiply.name]: multiply,
|
||||
[divide.name]: divide,
|
||||
};
|
||||
|
||||
export const arithmeticTools = Object.values(arithmeticToolsByName);
|
||||
Reference in New Issue
Block a user