OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

Custom Functions with parameters never called

Open miquellaboria opened this issue 1 year ago • 1 comments

Describe the bug I implement a custom function with parameters to be called form OpenAI API, but always call without the parameters:

To Reproduce Definition of Function ChatFunctionDeclaration ( name: "get_sleep_data", description: "Returns the sleep Data for an specified date", parameters: JSONSchema( type: .object, properties: [ "Sleepdate": .init(type: .string, description: "The date do you want to get the data for, in format yyyy-MM-dd") ], required: ["Sleepdate"] ) )

Viewing the body request to OpenAI:

"functions": [ { "parameters": { "properties": {}, "required": [], "type": "object" }, "name": "get_date_and_time", "description": "Returns the current date and time" }, { "name": "get_sleep_data", "parameters": { "properties": { "Sleepdate": { "type": "string", "description": "The date do you want to get the data for, in format yyyy-MM-dd" } }, "type": "object", "required": [ "Sleepdate" ] }, "description": "Returns the sleep Data for an specified date" } ],

But when OpenAI send a Call Function always send without parameter:

data: {"id”:”xxx,”object":"chat.completion.chunk","created":1703277440,"model":"gpt-4-1106-preview","system_fingerprint”:”xxx”,”choices":[{"index":0,"delta":{"role":"assistant","content":null,"function_call":{"name":"get_sleep_data","arguments":""}},"logprobs":null,"finish_reason":null}]}

Expected behavior The Function Call recives parameters.

Calls with NO parameters works fine.

Thanks for your help!

miquellaboria avatar Dec 22 '23 20:12 miquellaboria

I've been experiencing this same problem ever since I upgraded to the latest version of the MacPaw OpenAI Package. The arguments for every function call are empty, even when there are one or more parameters in the ChatQuery.ChatCompletionToolParam that are specified as "required". I've even experienced this problem when using the latest version's Demo's ChatStore class.

jeremypearson avatar May 31 '24 09:05 jeremypearson