Next code will be throw when configuration has maxTokens
let chat = OpenAI.Chat(model: \.gpt_4o_mini,
apiKey: .apiKey(Config.apiKey))
var configuration = chat.ConfigurationType.init()
configuration.maxTokens = 5
let stream = try await chat.streamCompletions(promt: "Please tell me about Space!", configuration: configuration)
for try await line in stream {
print(line)
}
The reason because answer is [DONE], not valid JSON, and
.asDecodedServerSentEventsWithJSONData(
of: Components.Schemas.CreateChatCompletionStreamResponse.self
)
cant decode it correctly.
Next code will be throw when configuration has maxTokens
The reason because answer is [DONE], not valid JSON, and
cant decode it correctly.