We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8040e4 commit e5000a9Copy full SHA for e5000a9
Shared/ChatGPTAPI.swift
@@ -100,9 +100,19 @@ class ChatGPTAPI: LLMClient, @unchecked Sendable {
100
}
101
102
var responseText = ""
103
+ let streams: AsyncThrowingStream<String, Error> = AsyncThrowingStream { continuation in
104
+ Task {
105
+ for try await line in result.lines {
106
+ try Task.checkCancellation()
107
+ continuation.yield(line)
108
+ }
109
+ continuation.finish()
110
111
112
+
113
return AsyncThrowingStream { [weak self] in
114
guard let self else { return nil }
- for try await line in result.lines {
115
+ for try await line in streams {
116
try Task.checkCancellation()
117
if line.hasPrefix("data: "),
118
let data = line.dropFirst(6).data(using: .utf8),
0 commit comments