On the function calling, what about if I have no parameter to call?

On the example they provide at the docummentation:

  const tools = [
    {
      type: "function",
      function: {
        name: "get_current_weather",
        description: "Get the current weather in a given location",
        parameters: {
          type: "object",
          properties: {
            location: {
              type: "string",
              description: "The city and state, e.g. San Francisco, CA",
            },
            unit: { type: "string", enum: ["celsius", "fahrenheit"] },
          },
          required: ["location"],
        },
      },
    },
  ];

What about when I have no parameter on the method?

I have tried a couple of options, such as leaving blank the parameters key, not passing it. It gives me back error.

The point is: the parameter is a local variable called ‘image’, which will change locally. I have tried to pass image as a variable as parameter, did not work.

I have an idea to interfere where the function is called, namely:

     const functionResponse = functionToCall(
        functionArgs.location,
        functionArgs.unit
      )

Replace by:

     const functionResponse = functionToCall(
        this.image
      )

I am using TypeScript.

Current solution that works: allows it pass a parameter, and just ignore the parameter; it is a dummy parameter, meaningless.

Wondering if we have a more elegant solution.

Similar question here.

1 Like

pass an empty object as a properties, for example, i do this:

      {
        type: 'function' as const,
        function: {
          name: 'getOrders',
          description: 'Get all the orders',
          parameters: {
            type: 'object',
            properties: {},
          },
        },
      },
1 Like

In fact, I have passed the whole parameters empty. Later I will try your way, who know, it may work!
Thanks :two_hearts:

The documentation states

To describe a function that accepts no parameters, provide the value {"type": "object", "properties": {}}

But they left out an important piece:

{
  "name": "getTranscript",
  "description": "Simply retrieves the user's current transcript when explicitly requested",
  "parameters": {
    "type": "object",
    "properties": {},
    "required": []
  }
}

You need to add "required": [] or else it throws an error

1 Like

Thanks.:heart_eyes::two_hearts::ok_hand:
I am not very patient reading documentation.
I have been using chatGPT in Bing for reading documentations, it works better for well-known documentations.

I have finally tested this solution, totally correct!:ok_hand::ok_hand::two_hearts::two_hearts:

1 Like

As this topic has a selected solution, closing topic.