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

Stream Error #170

Closed
abegehr opened this issue Feb 9, 2024 · 3 comments
Closed

Stream Error #170

abegehr opened this issue Feb 9, 2024 · 3 comments

Comments

@abegehr
Copy link

abegehr commented Feb 9, 2024

Describe the bug
I'm getting a Stream Error when trying to stream chat response:
Stream Error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected end of file" UserInfo={NSDebugDescription=Unexpected end of file})))

Sometimes it works for a few words and then fails, sometimes it fails directly.

To Reproduce
Steps to reproduce the behavior:

  1. Install OpenAI for Swift, latest version: 0.2.5 and init with token.
  2. Write a query with GPT4: let query = ChatQuery(model: .gpt4_1106_preview, messages: …)
  3. Run chatsStream(): for try await res in req.openAI.openAI.chatsStream(query: query) { … )
  4. Try to run it and see the error listed above

Expected behavior
I'd expect it not to error.

Screenshots
n.a.

Smartphone (please complete the following information):

  • Device: iPhone 15
  • OS: iOS 17.3

Additional context
n.a.

@abegehr
Copy link
Author

abegehr commented Feb 9, 2024

I've tested a few more models and it also fails on gpt3_5Turbo_1106, gpt3_5Turbo_16k. I've tried a few times on gpt3_5Turbo - which seems to have worked always. Possibly OpenAI sends some empty/non-json messages with newer models and the library is not prepared for that.

@ryanrapp
Copy link

Fixed in #154

@ingvarus-bc
Copy link
Contributor

Hi, thanks for reaching out!
Just tagged the release 0.2.6, the your issue is already fixed there 😉

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

3 participants