I'm using chat/completions with gpt-4, and am trying to use the streaming mode. But I see that in the request sent, stream parameter is set to false. Is there anything else I should be doing to stream, other than using streamedAnswer.ask ?
private func makeRequest(with text:String) async throws -> String? {
let request = ChatRequest.gpt4 { request in
request.messages = [
.init(role: .user, content: text)
]
request.temperature = Double(K.OpenAI.temperature)
request.maximumTokens = K.OpenAI.maxTokens
}
print("Making ChatGPT request: \(request)")
do {
var response = ""
for try await nextWord in try await chatGPT.streamedAnswer.ask(request: request) {
print("\(nextWord)")
response += nextWord
}
return response
} catch {
print("Error running chatgpt request: \(error.localizedDescription)")
return nil
}
}