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

Error on first run #1

Closed
markNZed opened this issue Mar 2, 2023 · 9 comments
Closed

Error on first run #1

markNZed opened this issue Mar 2, 2023 · 9 comments

Comments

@markNZed
Copy link

markNZed commented Mar 2, 2023

Hi, I get as far as:

Error: FormatException: SyntaxError: Unexpected non-whitespace character after JSON at position 209
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49        throw_
dart-sdk/lib/_internal/js_dev_runtime/patch/convert_patch.dart 39:5                 _parseJson
dart-sdk/lib/convert/json.dart 610:36                                               convert
dart-sdk/lib/convert/json.dart 216:41                                               decode
dart-sdk/lib/convert/json.dart 155:10                                               jsonDecode
packages/chatgpt_completions/src/repository/text_completions_repository.dart 63:34  <fn>
dart-sdk/lib/async/zone.dart 1593:10                                                runUnaryGuarded
dart-sdk/lib/async/stream_impl.dart 339:11                                          [_sendData]
dart-sdk/lib/async/stream_impl.dart 515:13                                          perform
dart-sdk/lib/async/stream_impl.dart 620:10                                          handleNext
dart-sdk/lib/async/stream_impl.dart 591:7                                           callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                                    _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                                     _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15                 <fn>

I have not used Flutter before so it may be something obvious. I ran the following in the example directory flutter run -d chrome

@lambiengcode
Copy link
Owner

Hi @markNZed, thanks for raise the issue!
This is the error when i convert the response from the api. I will fix it today...

@markNZed
Copy link
Author

markNZed commented Mar 3, 2023

Thanks. The error message from Flutter does not seem very helpful, is that typical in Flutter ? Is it hard to debug code in Flutter?

I noticed you are using text-davinci-003 so please be aware that is you add the gpt-3.5-turbo model then you need to use the openai.ChatCompletion as per https://platform.openai.com/docs/guides/chat/introduction and this changes the structures of the response too (compared to textCompletion).

@lambiengcode
Copy link
Owner

@markNZed I'm published version 0.0.4 with add the gpt-3.5-turbo and fix decode response from api... If any more errors are found, please let me know 🦁

@markNZed
Copy link
Author

markNZed commented Mar 3, 2023

Hi, I ran into this:

'''
Error: NoSuchMethodError: '[]'
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 768:3 defaultNoSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 762:56 noSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 283:12 callNSM
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 294:25 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:10 callMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 435:5 dsend
packages/chatgpt_completions/src/repository/text_completions_repository.dart 104:61 textCompletions
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50
dart-sdk/lib/async/zone.dart 1660:54 runUnary
dart-sdk/lib/async/future_impl.dart 147:18 handleValue
dart-sdk/lib/async/future_impl.dart 767:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 796:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 558:7 [_complete]
dart-sdk/lib/async/future_impl.dart 47:12 complete
dart-sdk/lib/async/future.dart 613:44 onValue
dart-sdk/lib/async/zone.dart 1660:54 runUnary
dart-sdk/lib/async/future_impl.dart 147:18 handleValue
dart-sdk/lib/async/future_impl.dart 767:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 796:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 567:5 [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 640:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15
'''

Could we use an environment variable for the OPENAI_API_KEY ?

@markNZed
Copy link
Author

markNZed commented Mar 3, 2023

For people who want to try your project and are not familiar with Flutter, it would help to have more detailed install instructions. I did this:

flutter pub get
add key to example/lib/main.dart
cd example
flutter run -d chrome

@lambiengcode
Copy link
Owner

lambiengcode commented Mar 3, 2023

@markNZed Example only dart not include UI, you should run dart main.dart instead of flutter run -d chrome

@markNZed
Copy link
Author

markNZed commented Mar 3, 2023

Sorry, I'm not sure to understand, there is an image of a UI in the readme, is that not actually part of this package?

@lambiengcode
Copy link
Owner

because I don't have enough times for write complete example app so I bring Askany app to README for demo video. Currently Askany has error occur, I'll update fix patch in tomorrow...and I'll deploy web example for people who want to try this package. You can download and use Askany in store:

Android: https://play.google.com/store/apps/details?id=com.askany
iOS: https://apps.apple.com/vn/app/askany/id1589217505

@markNZed
Copy link
Author

markNZed commented Mar 3, 2023

Thanks. I'm mainly interested in the web interface at the moment. I've been looking into https://github.com/YaokunLin/chatbot-react-client which has a separate client and server.

@PillarChen PillarChen mentioned this issue May 6, 2024
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