redevrx / chat_gpt_sdk

Flutter ChatGPT
https://pub.dev/packages/chat_gpt_sdk
MIT License
329 stars 171 forks source link

First Word Missing in onChatCompletionSSE Responses #69

Closed Abdullatif-Eida closed 12 months ago

Abdullatif-Eida commented 1 year ago

The onChatCompletionSSE response for generating a 200-word description of Turkey for example is experiencing an anomaly where the first word is returned as null or an empty string as shown belowÍ.

Screen Shot 2023-11-09 at 10 46 22

i am using the example shared by you

platform:IOS but also it occurs inside android chat_gpt_sdk 2.2.5 flutter doctor:

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.8, on macOS 12.6.8 21G725 darwin-x64, locale en-TR) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.83.1) [✓] Connected device (4 available) [✓] Network resources

redevrx commented 1 year ago

@Abdullatif-Eida Thank your for this report , this problem chunk in stream response , I will fix it.

garegintamrazyan07 commented 1 year ago

when can you fix this @redevrx ?

garegintamrazyan07 commented 1 year ago

@Abdullatif-Eida is there a workaround for this ?

redevrx commented 1 year ago

@garegintamrazyan07 You can try version 2.5.6 in this repo. https://pub.dev/packages/chat_gpt_sdk

garegintamrazyan07 commented 1 year ago

thanks, will check

garegintamrazyan07 commented 1 year ago

hey @redevrx , it seems that new version is not working ?

`Bad state: Cannot add new events after calling close flutter:

0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)

1 OpenAIClient.sse.. (package:chat_gpt_sdk/src/client/openai_client.dart:285:25)

2 _rootRun (dart:async/zone.dart:1391:47)

3 _ZoneDelegate.run (dart:async/zone.dart:952:19)

4 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29)

5 _ZoneDelegate.run (dart:async/zone.dart:952:19)

6 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29)

7 _ZoneDelegate.run (dart:async/zone.dart:952:19)

8 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29)

9 _ZoneDelegate.run (dart:async/zone.dart:952:19)

10 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29)

11 _CustomZone.run (dart:async/zone.dart:1301:19)

12 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)

13 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.da<…>`

onursahindur commented 1 year ago

hey @redevrx , it seems that new version is not working ?

Bad state: Cannot add new events after calling close flutter: #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24) #1 OpenAIClient.sse.<anonymous closure>.<anonymous closure> (package:chat_gpt_sdk/src/client/openai_client.dart:285:25) #2 _rootRun (dart:async/zone.dart:1391:47) #3 _ZoneDelegate.run (dart:async/zone.dart:952:19) #4 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #5 _ZoneDelegate.run (dart:async/zone.dart:952:19) #6 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #7 _ZoneDelegate.run (dart:async/zone.dart:952:19) #8 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #9 _ZoneDelegate.run (dart:async/zone.dart:952:19) #10 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #11 _CustomZone.run (dart:async/zone.dart:1301:19) #12 _CustomZone.runGuarded (dart:async/zone.dart:1209:7) #13 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.da<…>

same here

Abdullatif-Eida commented 1 year ago

hey @redevrx , it seems that new version is not working ?

Bad state: Cannot add new events after calling close flutter: #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24) #1 OpenAIClient.sse.<anonymous closure>.<anonymous closure> (package:chat_gpt_sdk/src/client/openai_client.dart:285:25) #2 _rootRun (dart:async/zone.dart:1391:47) #3 _ZoneDelegate.run (dart:async/zone.dart:952:19) #4 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #5 _ZoneDelegate.run (dart:async/zone.dart:952:19) #6 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #7 _ZoneDelegate.run (dart:async/zone.dart:952:19) #8 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #9 _ZoneDelegate.run (dart:async/zone.dart:952:19) #10 AsyncAction._run (package:mobx/src/api/async/async_action.dart:43:29) #11 _CustomZone.run (dart:async/zone.dart:1301:19) #12 _CustomZone.runGuarded (dart:async/zone.dart:1209:7) #13 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.da<…>

same issue here

tinyCoder32 commented 1 year ago

The new update doesn't work.

Fudal commented 1 year ago

+1

garegintamrazyan07 commented 1 year ago

@redevrx can we have a fix for this ?

tinyCoder32 commented 1 year ago

Hello, are you planning to fix it soon or shall we move to another package temporarily?

Abdullatif-Eida commented 1 year ago

go to pubspec.yaml the go to chat_gpt_sdk and make it chat_gpt_sdk: 2.2.5 and everything will work again event the First Word Missing in onChatCompletionSSE Responses issue is change but everything is working now

garegintamrazyan07 commented 1 year ago

@Abdullatif-Eida it is not working

tinyCoder32 commented 1 year ago

@Abdullatif-Eida it is not working

It worked for me, just clean the project and force the version:

chat_gpt_sdk: 2.2.5

prdgymx commented 1 year ago

Still experiencing this using 2.2.5 - seeing this in the debug console:

[OpenAI] stream response invalid try regenerate
[OpenAI] last json error :{"id":"chatcmpl-XXXXXXX","object":"chat.completion.chunk","created":1699997222,"model":"gpt-4-0613","choices":[{"index":0,"delta":{"rol
[OpenAI] stream response is done
gamestap99 commented 12 months ago

79

@Abdullatif-Eida @tinyCoder32 @Fudal @prdgymx @onursahindur done