When to use function calling
Use function calling when you need the model to:- Retrieve real-time or external data (e.g., weather info, stock prices)
- Perform computations not natively supported by the model
- Interact with APIs or databases
- Execute custom functions in your application
- As dictionaries: Specify the tool’s name, description, and parameters.
- As LangChain tools: Integrate tools from the LangChain library.
Example: Defining a tool as a dictionary
Example: Using a LangChain tool
Make a function call using the client
Considerations and limitations
- Model Support: Verify support using client.supports_function_calling(model).
- Tool Definitions: Ensure clarity to avoid incorrect calls.
- Execution: Handle tool execution and errors in your code.