An LLM isolated from the world is just a chatbot. By equipping models with the ability to define, invoke, and interpret tools (APIs, calculators, web browsers), they evolve into autonomous agents.
Module 1: Function Calling Architecture
Function calling works by injecting a JSON Schema of available tools into the system prompt. The model is trained to output a structured JSON payload requesting a tool execution rather than plain text, when it identifies a need for outside information.
Tool Definitionjavascript
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get the current weather for a location',
parameters: { type: 'object', properties: { location: { type: 'string' } } }
}
}