Function Calling
Learn how to use function calling with IronaAI to enable models to interact with external tools and APIs.
IronaAI supports function calling, allowing language models to interact with external tools, APIs, or custom functions. This feature enhances the model’s capabilities by enabling actions such as retrieving real-time data, performing computations, or accessing databases.
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
This is ideal for building interactive agents, automating workflows, or integrating AI into systems. Defining tools Tools can be defined in multiple ways:
-
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
The response includes a tool_calls attribute if the model opts to call a tool.
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.