Function calling is the bridge between the Imagination of the LLM and the Reality of your computer. It allows the AI to execute real C# code and interact with the real world.
In function calling, the 'API' is the description you write for your methods. If you describe a function as "Cancels a subscription based on user ID," the LLM will provide the `userId` and call that function whenever a user says "I want to quit."
Modern models can call multiple functions at once. If a user asks "What's the weather in London and Paris?", the AI will return TWO function calls in a single response, allowing your C# app to fetch both results in parallel for maximum speed.
Never let an LLM write and execute raw SQL. Instead, give it a function like `SearchCustomers(string name)`. The C# code inside that function should use parameterized queries and strict RBAC to ensure the AI cannot perform a 'Prompt Injection' on your database.
Q: "What is 'Few-shot Function Calling'?"
Architect Answer: "Sometimes the AI gets the parameters wrong. Few-shot function calling is when you provide examples of *previous* correctly formatted function calls in the prompt history. This 'Trains' the model on how to correctly map complex user requests to your specific C# method signatures, reducing errors by 70%."