adamrushy / OpenAISwift

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

Always returning nil #111

Open khandakerTR opened 11 months ago

khandakerTR commented 11 months ago

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):

Smartphone (please complete the following information):

Screenshot 2023-08-08 at 1 58 29 AM

Additional context Add any other context about the problem here.

marcoboerner commented 10 months ago

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

mattaimin commented 10 months ago

I got the same issue

mattaimin commented 10 months ago

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