Function Calling
Function Calling
empowers AI models to interact with external tools and APIs, enabling them to perform specific actions and access real-time information. This capability extends the functionality of AI models beyond simple text generation, allowing for more dynamic and practical applications.
Supported Models
The following models support Function Calling:
- deepseek/deepseek_v3
Quick Start Guide
This guide demonstrates how to use Function Calling to retrieve current weather information for a user’s specified location. We will walk through a complete Python code example.
For the specific API format of Function Calling, please refer to the API reference Create Chat Completion.
1. Initialize the Client
First, you need to initialize the client with your Novita API key.
2. Define the Function to Be Called
Next, define the Python function that the model can call. In this example, it’s a function to get weather information.
3. Construct the API Request with Tools and User Message
Now, create the API request to the Novita endpoint. This request includes the tools
parameter, defining the functions the model can use, and the user’s message.
Output:
4. Respond with the Function Call Result and Get the Final Answer
The next step is to process the function call, execute the get_weather
function, and send the result back to the model to generate the final response to the user.
Output:
The Complete Code
Was this page helpful?