Skip to content

Commit 70aec2d

Browse files
committed
fix: simplify RAG streaming actor updates
1 parent 212d70f commit 70aec2d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Foundation Lab/ViewModels/RAGChatViewModel.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ private extension RAGChatViewModel {
424424
)
425425
let task = Task { @MainActor [streamingTextUseCase] in
426426
let result = try await streamingTextUseCase.execute(request) { partialResponse in
427-
await MainActor.run {
428-
entry.content = partialResponse
429-
}
427+
await updateStreamingEntry(entry, with: partialResponse)
430428
}
431429
self.lastTokenCount = result.metadata.tokenCount
432430
}
@@ -441,4 +439,9 @@ private extension RAGChatViewModel {
441439
if entry.content.isEmpty { entry.content = "Failed: \(error.localizedDescription)" }
442440
}
443441
}
442+
443+
@MainActor
444+
private func updateStreamingEntry(_ entry: RAGChatEntry, with partialResponse: String) {
445+
entry.content = partialResponse
446+
}
444447
}

0 commit comments

Comments
 (0)