Function Calling
Function Calling (Tool Use)
What is it?
Function Calling (or Tool Use) is the capability of an LLM to recognize when it needs external help and to output a structured command (usually JSON) to call a specific function.
Instead of writing a poem about the weather, the model outputs: get_weather(city="London"). The application executes this code and feeds the result back to the model.
Why is it Important?
- Action over Text: It transforms the LLM from a passive chatbot into an active agent that can manipulate the world (send emails, query databases, book tickets).
- Structured Output: It forces the notoriously unpredicatable LLM to output clean, reliable data structures like JSON, making integration with traditional software possible.
- Deterministic Operations: It allows the model to offload math or logic to calculators/scripts, where LLMs typically struggle.
Technical View
The “loop” involves the model pausing generation to ask for a tool execution.