You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm actually making calls to large language models and I need to capture part of the result. The LLM's stream the data with SSE.
So my question is, how can I somehow intercept the stream below and pull out certain data before it is streamed to the browser?
asyncfnhandler(State(client):State<Client>,mutreq:Request) -> Result<Response,StatusCode>{
....
let uri = format!("http://127.0.0.1:3000{}", path_query);*req.uri_mut() = Uri::try_from(uri).unwrap();// I want to somehow intercept the stream, process it on the fly and continue....???Ok(client
.request(req).await.map_err(|_| StatusCode::BAD_REQUEST)?
.into_response())}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
I current have a reverse proxy running based on the example code https://github.com/tokio-rs/axum/blob/main/examples/reverse-proxy/src/main.rs#L40
That works fine.
I'm actually making calls to large language models and I need to capture part of the result. The LLM's stream the data with SSE.
So my question is, how can I somehow intercept the stream below and pull out certain data before it is streamed to the browser?
axum version
0.7.5
Beta Was this translation helpful? Give feedback.
All reactions