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

Version 0.2.0 breaks example with completion #71

Closed
jean-bovet opened this issue May 17, 2023 · 3 comments
Closed

Version 0.2.0 breaks example with completion #71

jean-bovet opened this issue May 17, 2023 · 3 comments

Comments

@jean-bovet
Copy link

Describe the bug
The latest version, 0.2.0, break the completion example, likely due to the stream being true and the decoding not expecting the JSON format which OpenAI returns.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Xcode project
  2. Use the example of the prompt in the README:
  3. let query = CompletionsQuery(model: .textDavinci_003, prompt: "What is 42?", temperature: 0, max_tokens: 100, top_p: 1, frequency_penalty: 0, presence_penalty: 0, stop: ["\\n"]) openAI.completions(query: query) { result in //Handle result here } //or let result = try await openAI.completions(query: query)
  4. Run the example and observe the following error:
  5. failure(Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around line 1, column 0." UserInfo={NSDebugDescription=Invalid value around line 1, column 0., NSJSONSerializationErrorIndex=0}))))

Expected behavior
Reverting to the version before 0.2.0 works fine with an expected result without error.

Desktop (please complete the following information):

  • OS: macOS 13.3.1
@Krivoblotsky
Copy link
Collaborator

Hey, @jean-bovet.
Thanks for reporting.
My bad, forgot to switch the streaming off by default.
Just fixed it with https://github.com/MacPaw/OpenAI/releases/tag/0.2.1

Thanks!

@jean-bovet
Copy link
Author

Thanks @Krivoblotsky for the quick turn-around. Much appreciated! May I suggest adding unit tests around this in the future?

@Krivoblotsky
Copy link
Collaborator

Sure, I’ll add it with next release 👌

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