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

Exception on image.create with b64json responseFormat #31

Closed
rxlabz opened this issue Mar 30, 2023 · 1 comment
Closed

Exception on image.create with b64json responseFormat #31

rxlabz opened this issue Mar 30, 2023 · 1 comment

Comments

@rxlabz
Copy link
Contributor

rxlabz commented Mar 30, 2023

You can't actually call the image.create if you choose the b64 response :

final response = await OpenAI.instance.image.create(
    prompt: prompt,
    n: 1,
    size: OpenAIImageSize.size256,
    responseFormat: OpenAIImageResponseFormat.b64Json,
  );

When you do you get this exception

Unhandled exception:
type 'Null' is not a subtype of type 'String'
#0      new OpenAIImageData.fromMap (package:dart_openai/src/core/models/image/image/sub_models/data.dart:18:37)
#1      new OpenAIImageModel.fromMap.<anonymous closure> (package:dart_openai/src/core/models/image/image/image.dart:29:39)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#6      new List.of (dart:core-patch/array_patch.dart:52:28)
#7      ListIterable.toList (dart:_internal/iterable.dart:214:7)
#8      new OpenAIImageModel.fromMap (package:dart_openai/src/core/models/image/image/image.dart:30:12)
#9      OpenAIImages.create.<anonymous closure> (package:dart_openai/src/instance/images/images.dart:72:45)
#10     OpenAINetworkingClient.post (package:dart_openai/src/core/networking/client.dart:130:23)
<asynchronous suspension>
#11     OpenAIImages.create (package:dart_openai/src/instance/images/images.dart:70:12)
<asynchronous suspension>
#12     requestImg (package:gpt_api/gpt_api.dart:45:20)
<asynchronous suspension>
#13     generateFicheImages (file:///Users/rxlabz/projects/lilu/lilu023/protos/gpt_api/bin/gpt_api.dart:108:25)
<asynchronous suspension>
#14     saveLesson (file:///Users/rxlabz/projects/lilu/lilu023/protos/gpt_api/bin/gpt_api.dart:69:5)
<asynchronous suspension>
#15     main (file:///Users/rxlabz/projects/lilu/lilu023/protos/gpt_api/bin/gpt_api.dart:36:3)
<asynchronous suspension>

It's because the OpenAIImageData constructor wait for a non nullable url, and not for the b64json data.

rxlabz added a commit to rxlabz/openai that referenced this issue Mar 30, 2023
allow instantiate from a OpenAIImageResponseFormat.b64Json response
@anasfik
Copy link
Owner

anasfik commented Apr 9, 2023

Thank you for the notice!

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