Forge.OpenAI icon indicating copy to clipboard operation
Forge.OpenAI copied to clipboard

Problems using tools/function (ChatToolFunction) with Parameters as a string

Open stiz0r opened this issue 11 months ago • 2 comments

In your framework you have added "parameters" in the ChatToolFunction as a string. I cannot get it to work with just adding JSON in this string.

It is defined as as "object" in the documentation: https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools

This probably needs to be an object with the settings possible, like type, properties and required. Properties as its own object - with something dynamic because names like emotion and language are specific for this case.

When I create my own full JSON payload like below, where parameters is a normal object with no " around the parameters content, it works. { "tools": [ { "type": "function", "function": { "description": "Classify the relevant information from the phrase.", "name": "getinformation", "parameters": { "type": "object", "properties": { "emotion": { "type": "string", "description": "The emotion of the phrase." }, "language": { "type": "string", "description": "The language of the phrase." } }, "required": [ "emotion", "language" ] } } } ] }

Errormessage example: { "error": { "message": ""{'type': 'object', 'properties': {'language': {'type': 'string','description': 'The language of the phrase.' }}}" is not of type 'object' - 'tools.0.function.parameters'", "type": "invalid_request_error", "param": null, "code": null } }

stiz0r avatar Mar 01 '24 09:03 stiz0r

Hello, You are right, nice catch. Thank you, it has a fix in version 1.3.1.

JZO001 avatar Mar 03 '24 14:03 JZO001

I just tested i now, thanks for the quick fix.

stiz0r avatar Mar 04 '24 08:03 stiz0r