openai icon indicating copy to clipboard operation
openai copied to clipboard

fix(model): image_url changed to object from string as specified in OpenAI API spec

Open MbBrainz opened this issue 1 year ago • 3 comments
trafficstars

I noticed the request Exception below and went searching.

As discussed in the openai community forum here The image_url should be an object and not a string. In the current implementation, the image_url will be set as a string and this will always result in the following response from the openai api:

RequestFailedException(message: Invalid type for 'messages[1].content[0].image_url': expected an object, but got a string instead

In the forum discussion, it is mentioned that the api specs were outdated, but its not anymore as specified under the image tab at the openai chat completion api spec

MbBrainz avatar Sep 29 '24 20:09 MbBrainz

@anasfik @signmotion

MbBrainz avatar Sep 30 '24 07:09 MbBrainz

Fixes #191

MbBrainz avatar Oct 01 '24 11:10 MbBrainz

I think this also needs a change https://github.com/anasfik/openai/blob/8cbc06107b912f7d6adeae818a107ed8dba7fea3/lib/src/core/models/chat/sub_models/choices/sub_models/sub_models/content.dart#L62

The type needs to be "image_url". I found that to work and it also matches the docs

RuABraun avatar Dec 29 '24 18:12 RuABraun