Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lukehutch opened this issue Dec 4, 2024 · 3 comments

Comments

@lukehutch
Copy link

When trying the chat example, I get:

RequestFailedException(message: Invalid type for 'messages[1].content[1].image_url': expected an object, but got a string instead., statusCode: 400)
#0      OpenAINetworkingClient.post (package:dart_openai/src/core/networking/client.dart:332:7)
<asynchronous suspension>
#1      OpenAIChat.create (package:dart_openai/src/instance/chat/chat.dart:87:12)
<asynchronous suspension>
#2      run (package:qa/qa.dart:68:46)
<asynchronous suspension>
#3      main (file:///Users/lhutchison/qa/bin/qa.dart:8:3)
<asynchronous suspension>
@pagebook1
Copy link

pagebook1 commented Dec 14, 2024

Same error.. it's because of image_url . please fix thanks ..

@pagebook1
Copy link

pagebook1 commented Dec 14, 2024

I fixed it.. try to make a pr.
i changed the content.dart line 55 from
Map<String, dynamic> toMap() { return { "type": type, if (text != null) "text": text, if (imageUrl != null) "image_url": imageUrl, }; }
to
Map<String, dynamic> toMap() { return { "type": type, if (text != null) "text": text, if (imageUrl != null) "image_url": { "url": imageUrl, }, }; }

it should be a object (map) but in the line 55 it throws only a String that's why its error.

@pagebook1
Copy link

as I see on the latest pr, it's fixed but still not updated on the pub.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants