anasfik / openai

Dart/Flutter SDK for ChatGPT and all OpenAI APIs (GPT, Dall-e..)
https://pub.dev/packages/dart_openai
MIT License
591 stars 184 forks source link

Error when using OpenAI.instance.completion.create #186

Closed richardchui closed 4 months ago

richardchui commented 4 months ago

When using OpenAI.instance.completion.create, the request finished successfully and then threw the following errors:

E/flutter (25549): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'int' E/flutter (25549): #0 new OpenAICompletionModelChoice.fromMap (package:dart_openai/src/core/models/completion/sub_models/choice.dart:47:18) E/flutter (25549): #1 new OpenAICompletionModel.fromMap. (package:dart_openai/src/core/models/completion/completion.dart:71:51) E/flutter (25549): #2 MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31) E/flutter (25549): #3 ListIterator.moveNext (dart:_internal/iterable.dart:354:26) E/flutter (25549): #4 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27) E/flutter (25549): #5 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28) E/flutter (25549): #6 new List.of (dart:core-patch/array_patch.dart:39:18) E/flutter (25549): #7 ListIterable.toList (dart:_internal/iterable.dart:224:7) E/flutter (25549): #8 new OpenAICompletionModel.fromMap (package:dart_openai/src/core/models/completion/completion.dart:72:12) E/flutter (25549): #9 OpenAICompletion.create. (package:dart_openai/src/instance/completion/completion.dart:144:38) E/flutter (25549): #10 OpenAINetworkingClient.post (package:dart_openai/src/core/networking/client.dart:336:23) E/flutter (25549): E/flutter (25549): #11 OpenAICompletion.create (package:dart_openai/src/instance/completion/completion.dart:123:12) E/flutter (25549): E/flutter (25549): #12 AIService.getCompletion (package:conversation/services/ai.service.dart:10:40) E/flutter (25549):