AI Fundamentals - Part 4: Building Real AI Applications
In the previous articles, we learned how an LLM generates text and how techniques like RAG and CAG help it answer questions using external knowledge. At this point, our AI-powered Travel Planner can answer questions like "I'm visiting Japan for 7 days. Suggest an itinerary." or "Recommend vegetarian ramen near Tokyo Station." That's useful, but it's still just a chatbot. What if the user asks to "Book the cheapest flight from Mumbai to Tokyo." , "What's the weather in Kyoto this weekend?" , or "Remember that I prefer vegetarian food and always choose a window seat." ? An LLM cannot execute these actions by itself. To build real, production-ready AI applications, we need to connect the model to the outside world. Let's see how that works. Tool Calling (Function Calling): Letting AI Use External Tools Suppose the user asks: "What's the weather in Kyoto tomorrow?" Since the LLM doesn't know tomorrow's forecast, our application can provide the model with a weather API. The workflow is simple: the LLM understands the request, determines that it needs the weather tool, calls the Weather API (via the client application), receives the live weather data, and generates the final grounded response. User ──► LLM understands request ──► Application calls API ──► App sends results ──► LLM response It's critical to understand that the LLM isn't calling the API directly . It simply outputs structured instructions (typically JSON) telling the client application: "To answer this, I need you to call the weather function with parameter location='Kyoto'." Your application executes the actual API call and feeds the result back to the model. This capability is called function calling or tool calling . The tool can be anything: a weather API, a flight booking service, a calendar, a database, a payment gateway, or an internal company system. The LLM acts as the decision-maker (determining which tool to use and when ), while your application acts as the executor. 💡 Developer's Takeaway Think