adamrushy / OpenAISwift

This is a wrapper library around the ChatGPT and OpenAI HTTP API
MIT License
1.6k stars 242 forks source link

BUG: OpenAISwift sendCompletion returns nils #71

Open azamsharp opened 1 year ago

azamsharp commented 1 year ago

I updated the packages and the decoding error is now gone but when I make a request I get the following:

OpenAI<TextResult>(object: nil, model: nil, choices: nil, usage: nil, data: nil)

openAI.sendCompletion(with: chatText, maxTokens: 500) { result in
            switch result {
                case .success(let success):
                  // OpenAI<TextResult>(object: nil, model: nil, choices: nil, usage: nil, data: nil)
                    print(success) 

The success contains all nil values.

adamrushy commented 1 year ago

Interesting! Looking now 👍🏼

adamrushy commented 1 year ago

@azamsharp can you stick a breakpoint LOC 209 inside OpenAISwift.swift file? Then print out the response from the API? This is likely to be caused by an error from the API. For example, my account is giving me a 429 for rate limit on the free account.

azamsharp commented 1 year ago

Found the solution. I used a different openChat function and read the actual error. It was related to quote limit expired. I put in my credit card with some limit and now everything worked. Thanks for your help!

aravasio commented 1 year ago

The library can definitely improve the way it communicates errors. I had to do a little bit of browsing to figure out error 429 was holding me back, too.

I think I can work on this over these few days, would you be interested in a PR? Or would you rather work on this on your own?

cmedlej commented 11 months ago

@azamsharp can you stick a breakpoint LOC 209 inside OpenAISwift.swift file? Then print out the response from the API? This is likely to be caused by an error from the API. For example, my account is giving me a 429 for rate limit on the free account.

How do you fix this error?