rustvital-amd / src /api /stream.rs
brainworm2024's picture
Phase 2: SSE streaming, asymmetric rehydration, fine-tuning trigger
eff14fc
raw
history blame contribute delete
519 Bytes
use axum::response::sse::{Event, KeepAlive, Sse};
use futures::stream::Stream;
use std::convert::Infallible;
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
pub async fn triage_stream(
patient_note: String,
) -> Sse<impl Stream<Item = Result<Event, Infallible>>> {
let (tx, rx) = mpsc::channel(100);
tokio::spawn(async move {
let _ = crate::orchestrator::run_triage_stream(patient_note, tx).await;
});
Sse::new(ReceiverStream::new(rx)).keep_alive(KeepAlive::default())
}