OpenAISwift icon indicating copy to clipboard operation
OpenAISwift copied to clipboard

BUG: OpenAISwift sendCompletion returns nils

Open azamsharp opened this issue 1 year ago • 5 comments

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.

azamsharp avatar Apr 05 '23 12:04 azamsharp

Interesting! Looking now 👍🏼

adamrushy avatar Apr 05 '23 13:04 adamrushy

@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.

adamrushy avatar Apr 05 '23 13:04 adamrushy

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!

azamsharp avatar Apr 05 '23 13:04 azamsharp

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?

aravasio avatar Apr 06 '23 09:04 aravasio

@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?

cmedlej avatar Jul 21 '23 18:07 cmedlej