OpenAISwift icon indicating copy to clipboard operation
OpenAISwift copied to clipboard

Always returning nil

Open khandakerTR opened this issue 11 months ago • 3 comments

Describe the bug I write a function in Swift to search in ChatGpt here is my function

    func performSearch() {
        openAI.sendCompletion(with: "what is chat gpt", maxTokens: 500) { result in
            switch result {
            case .success(let response):
                print("Response ",response)
                let answer = response.choices?.first?.text.trimmingCharacters(in: .whitespacesAndNewlines)
            case .failure(let failure):
                print("Failed")
            }
        }
    }

To Reproduce Steps to reproduce the behavior:

  1. Just call this performSearch() method

Expected behavior It should return with some response or error

Screenshots I added screenshot of printing the response

Desktop (please complete the following information):

  • xCode 14.3.1

Smartphone (please complete the following information):

  • iOS 16.4 (simulator)
Screenshot 2023-08-08 at 1 58 29 AM

Additional context Add any other context about the problem here.

khandakerTR avatar Aug 07 '23 20:08 khandakerTR

@khandakerTR I'd recommend using something like Charles (with its SSL Proxy active and Certificate installed on the Simulator) to see exactly what the error is. It might give you more details.

marcoboerner avatar Aug 08 '23 18:08 marcoboerner

I got the same issue

mattaimin avatar Aug 16 '23 04:08 mattaimin

I fixed it by activating the openAI API account by entering the credit card info.....It is not the same as ChatGPT account

mattaimin avatar Aug 16 '23 12:08 mattaimin