Function Calling
Function Calling is the process by which a large language model (LLM) identifies the intent behind a user's request and outputs, in a predefined format, the parameters needed to invoke an external tool or function.
How it works
At its core, it is a specialized prompt engineering technique that enables LLMs to interact with the outside world (such as databases, APIs, and calculators). By converting users' natural language instructions into structured function call requests, it greatly extends the capability boundaries of AI models and is a key technology for building AI agents and automating complex workflows.
Examples
- 1.A user says 'Book me a flight from Beijing to Shanghai for tomorrow.' The AI recognizes the 'book a flight' intent and generates a function call with parameters such as date, origin, and destination, which is then executed by the booking system.
- 2.In a data analysis scenario, when a user asks 'Which product had the highest sales last month?', the AI can generate an SQL function call that queries the database to retrieve an accurate result.
- 3.When a user asks to 'translate these meeting minutes into French and summarize the key points', the AI can call a translation API and a text summarization function in sequence to complete the compound task.