| 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()) | |
| } | |