#can you tell me about the "tools" parameter in the api
1 messages · Page 1 of 1 (latest)
Hi @livid obsidian. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The "tools" parameter in the OpenAI API is used to describe the functions that the AI model can call. It is an array that contains one object per function. Each object has two keys: type and function. The function key has three subkeys: name, description, and parameters.
Here is an example of how to define the "tools" parameter:
const tools = [
{
type: "function",
function: {
name: "getCurrentWeather",
description: "Get the current weather in a given location",
parameters: {
type: "object",
properties: {
latitude: {
type: "string",
},
longitude: {
type: "string",
},
},
required: ["longitude", "latitude"],
},
}
},
{
type: "function",
function: {
name: "getLocation",
description: "Get the user's location based on their IP address",
parameters: {
type: "object",
properties: {},
},
}
},
];
In this example, there are two functions defined: getCurrentWeather and getLocation. Each function has a description and parameters. The parameters are defined as an object with properties and required fields.
The "tools" parameter has replaced the deprecated function_call and functions parameters. However, as of the current state, the fine-tuning API still requires the legacy format.
For more information, you can refer to the OpenAI documentation (https://platform.openai.com/docs/api-reference) and the OpenAI community forum (https://community.openai.com/t/499313).
Sources:
- How to build an agent with the Node.js SDK (https://cookbook.openai.com/examples/how_to_build_an_agent_with_the_node_sdk#describing-our-functions-for-openai)
- Forum Post: Preparing data to fine-tune function-calling model (https://community.openai.com/t/499313)