<aside> ๐๏ธ
Date: Friday, October 9, 2026 ยท Week 2, Day 12 ยท Type: Build Day + Live Session 4 (7:30 PM IST, 90 min)
</aside>
12.1 Extending LLMs with Tools โ how an LLM decides when to call an external function (e.g., calculator, weather API, database lookup).
12.2 Function Schemas โ describing Python functions to an LLM using JSON schemas (name, description, parameter types).
12.3 The Execution Loop โ model returns function name & arguments โ local app runs function โ result fed back to model โ final answer generated.
Build an "AI Math Assistant" that gives an LLM access to two local Python tools (calculate(expression) and get_stock_price(ticker)), parses the model's tool-call request, executes the Python function, and returns the verified answer.
+-------------+ +--------------------+ +------------------------+
| User Query | --> | LLM Decision Engine| --> | Tool Call Request JSON |
+-------------+ +--------------------+ +------------------------+
|
v
[Final Answer] <--- [Feed Result Back to LLM] <--- [Execute Python Tool]
Problem 12. Build a Python tool dispatcher class ToolRegistry where functions can be registered using a @register_tool decorator, and an execute(tool_name, **kwargs) method dynamically validates arguments and executes the corresponding function.
Data Structure: Function Lookup Registry (Dispatch Table).
Mechanics: Hash map storing function names mapped directly to executable Python callable references.
Real-World Production Use: Core mechanism inside OpenAI Assistant SDK, LangChain Agents, and Semantic Kernel.