Generate Tool Call
You can translate a prompt into arguments for a single tool call with generateToolCall. The model that you provide needs to support tools calls (e.g. OpenAI Chat).
note
generateToolCall
function does not execute the tool.
It only generates the arguments for the tool call.
You can execute the tool with runTool or executeTool.
Example
const { id, name, args } = await generateToolCall({
model: openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }),
tool: calculator,
prompt: [openai.ChatMessage.user("What's fourteen times twelve?")],
});
console.log(`Tool ID: ${id}`);
console.log(`Tool name: ${name}`);
console.log(`Tool arguments: ${JSON.stringify(args, null, 2)}`);
Available Providers
- OpenAI (Chat models)