Tool Use & Function Calling
What is Tool Use?
Tool use (function calling) allows LLMs to invoke external functions — web search, calculators, databases, APIs — instead of generating an answer from memory alone. This overcomes the key limitations of LLMs: outdated knowledge, inability to perform exact computation, no access to private data.
How It Works
1. You define tools with a name, description, and parameter schema (JSON Schema) 2. LLM decides which tool to call and with what arguments based on the user's request 3. Your code executes the tool with the provided arguments 4. Tool result is returned to the LLM 5. LLM generates a final response incorporating the result This loop can repeat multiple times for complex tasks.
Function Calling Example
Never eval() user-provided input in production — use a safe math parser like simpleeval or sympy.
Finished reading? Mark it complete to earn your XP.