Maths
Guide to use Maths tool on your AI agent using Vity Toolkit
Quick Start
1
npm install vity-toolkit langchain @langchain/openai2
import { ChatOpenAI } from "@langchain/openai";
import { App, LangchainToolkit } from "vity-toolkit";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
const model = new ChatOpenAI({ model: "gpt-4o" });
const toolKit = new LangchainToolkit();3
const tools = toolKit.getTools({ apps: [App.BASIC_MATH] });4
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a precise calculator that can perform simple math using the Basic Math tool."],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm: model, tools, prompt });
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: false,
});5
const response = await agentExecutor.invoke({ input: "Multiply 4 and 8, then tell me the result." });
console.log(response);Supported Actions
Action
Description
Action.BASIC_MATH_SOLVELast updated