diff --git a/Sources/OpenAI/Private/StreamingSession.swift b/Sources/OpenAI/Private/StreamingSession.swift index 36099d98..c368536f 100644 --- a/Sources/OpenAI/Private/StreamingSession.swift +++ b/Sources/OpenAI/Private/StreamingSession.swift @@ -61,6 +61,7 @@ extension StreamingSession { return } let jsonObjects = "\(previousChunkBuffer)\(stringContent)" + .trimmingCharacters(in: .whitespacesAndNewlines) .components(separatedBy: "data:") .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } .filter { $0.isEmpty == false }