Randomizer
Guide to use Randomizer tool on your AI agent using Vity Toolkit
Offer coin flips, dice rolls, yes/no answers, or pick-from-list randomness for lightweight decisions.
Quick Start
1
Install the package.
npm install vity-toolkit langchain @langchain/openai2
Initialize Vity Toolkit and Langchain.
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
Add the tool.
const tools = toolKit.getTools({ apps: [App.RANDOMIZER] });4
Define the Agent.
const prompt = ChatPromptTemplate.fromMessages([
["system", "Use the Randomizer tool for coin flips, dice rolls, yes/no choices, or selecting from a list."],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm: model, tools, prompt });
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: false,
});5
Execute the Agent.
const response = await agentExecutor.invoke({
input: "Roll a virtual dice to help me decide which board game to start with.",
});
console.log(response);Supported Actions
Action
Description
Action.RANDOMIZER_RUNGenerate playful randomness via coin flips, dice rolls, yes/no decisions, or picking from a custom list.
Last updated