adamrushy / OpenAISwift

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

.gpt4 is not working, returning empty string #105

Open antqin opened 11 months ago

antqin commented 11 months ago

I'm running the following code using the model .gpt4(.gpt4) but the output is an empty string. My account is approved for gpt-4, which I verified by running gpt-4 in the playground on OpenAI. Any help/ideas is appreciated!

Here is my getResponse code: public func getResponse(input: String, completion: @escaping (Result<String, Error>) -> Void) { client?.sendCompletion(with: input, model: .gpt4(.gpt4), maxTokens: 500, completionHandler: { result in switch result { case .success(let model): let output = model.choices?.first?.text ?? "" completion(.success(output)) case .failure(let error): completion(.failure(error)) } }) }

tirnaltd commented 10 months ago

I've got the same problem. No matter what combo of gpt4 models, max token sizes and temperatures I use, it won't work. I'm approved for GPT4 8k context, and I can use it in the playground. I've noticed in the playground that GPT4 is only available for chats and not completions. Is this relevant to my problem?

let result = try await openAI.sendCompletion( with: "This is an example text", model: .other("gpt-4"), // optional OpenAIModelType maxTokens: 8192, // optional Int? temperature: 0.1 // optional Double? )