This tool definition
{
"type": "function",
"function": {
"name": "getWeather",
"description": "This function returns the weather for a given location.",
"parameters": {
"type": "object",
"properties": {
"locations": {
"description": "The location to get the weather for.",
"type": "array",
"items": {
"type": "string",
"enum": ["Nashville", "New York", "Seattle"],
},
},
},
"required": ["location"],
}
}
}
Gets encoded as
// This function returns the weather for a given location.
type getWeather = (_: {
// The location to get the weather for.
locations?: "Nashville" | "New York" | "Seattle"[],
}) => any;
The encoding for the locations
argument is missing parentheses. It should be ("Nashville" | "New York" | "Seattle")[]
A parameter defined as
"num_days": {
"description": "The number of days to get the weather for.",
"type": "integer",
"enum": [1, 2, 3, 4, 5, 6, 7],
},
gets encoded as
// The number of days to get the weather for.
num_days?: "1" | "2" | "3" | "4" | "5" | "6" | "7",
Which is incorrect because these are strings rather than ints.