Tauhid Zaman | Yale SOM
Standard chatbots are like brilliant scholars locked in a room.
We give the chatbot access to a set of tools
Natural Language
Tool Calling
Automated Action
How a chat becomes action
(Press Down ↓ to see the code contract)
{
"name": "generateMovieScript",
"description": "Updates the scene editor with a new script",
"parameters": {
"type": "object",
"properties": {
"scenes": {
"type": "array",
"items": {
"type": "object",
"properties": { "description": "string", "narration": "string" }
}
}
},
"required": ["scenes"]
}
}
The "Invisible Handshake"
{
"functionCall": {
"name": "generateMovieScript",
"args": {
"scenes": [
{ "description": "Neon city...", "narration": "Welcome..." }
]
}
}
}
How the app handles the chatbot's request.
async function handleChat(userInput) {
const result = await chat.sendMessage(userInput);
// 1. Check if Gemini requested a Tool
const call = result.response.functionCalls()?.[0];
if (call?.name === "generateMovieScript") {
// 2. EXECUTION: Run the local React function
handleAssistantScript(call.args.scenes);
return "I've updated the editor for you!";
}
return result.response.text();
}
handleAssistantScript function with the parameters.
handleAssistantScript function with the parameters.| Feature | Traditional UI | AI Tools |
|---|---|---|
| Input | Forms & Buttons | Conversation |
| Accuracy | Manual Data Entry | AI Assisted Data Generation |
| Flexibility | Rigid Workflow | Dynamic Workflow |
run_python() tool to generate charts, run regressions, and analyze the results.trade_crypto() tool to execute buy/sell orders based on a strategy.