Is it possible to have two arguments in a function call?

Let’s say we have this function:
const updateInfo = async (currentInfo, newInfo) => {
const payload = {
model: “gpt-3.5-turbo-0613”,
messages: [
{
role: “user”,
content: currentInfo, newInfo
},
functions: [
{
name: “updateInfo”,
description: “update the current info with the new info”
}
]
…rest for the code
]
}

I’m asking because from all the examples I’ve seen, only one argument is being used

Sure! Make your weather function require the city, the date range, simple or extended forecast…

What you show isn’t a complete function definition for the AI to use though.

Below is an example function specification that you provide to a chat completions “functions” API parameter (showing all types except “array”, where instructing multiple items to be output, like 5 keywords, takes more high-quality function description).

functions = [
{
    "name": "data_demonstration",
    "description": "This is the main function description",
    "parameters": {
        "type": "object",
        "properties": {
"string_1": {"type": "string", "description": ""},
"number_2": {"type": "number", "description": ""},
"boolean_3": {"type": "boolean", "description": ""},
"empty_4": {"type": "null","description": "This is a description of the empty_4 null property"},
"string_5_enum": {"type": "string", "enum": ["Happy", "Sad"]},
        },
        "required": ["string_1","number_2","boolean_3", "empty_4", "string_5_enum"]
    }
}
]

string_1 and so forth are the names.

Ask the AI to just call its function to test all the parameters, and you’d get this creative output:

{
  ..
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "function_call": {
          "name": "data_demonstration",
          "arguments": "{
  "string_1": "Hello",
  "number_2": 42,
  "boolean_3": true,
  "empty_4": null,
  "string_5_enum": "Happy"
}"
        }
      },
      "finish_reason": "function_call"
    }
  ],...

One big caveat is that the AI will often make up values within multiple parameters for which it doesn’t have enough information. That takes a bit more specification about where every source of information must come from, and that the function can’t be used unless a value for all parameters is seen or found.


If you actually want completely separate functions to be able to be called, each with their own set of arguments, you’d use the parallel tool-call ability of “tools”, where, for example, the AI could ask for three different forecasts from a function that only supports one city at a time.

2 Likes

Thanks for the response. What I asked though was the possibility of having two parameters (maybe I shouldn’t have called parameters because function calling has parameters that mean something else). I should have probably be more specific. By parameters I meant the content that’s passed down to the function.