diff --git a/crates/brightstaff/src/handlers/response_handler.rs b/crates/brightstaff/src/handlers/response_handler.rs index aa36d621..9d7726e3 100644 --- a/crates/brightstaff/src/handlers/response_handler.rs +++ b/crates/brightstaff/src/handlers/response_handler.rs @@ -116,8 +116,8 @@ impl ResponseHandler { /// Collect the full response body as a string /// This is used for intermediate agents where we need to capture the full response - /// before passing it to the next agent. - /// + /// before passing it to the next agent. + /// /// This method handles both streaming and non-streaming responses: /// - For streaming SSE responses: parses chunks and extracts text deltas /// - For non-streaming responses: returns the full text @@ -126,22 +126,22 @@ impl ResponseHandler { llm_response: reqwest::Response, ) -> Result { use hermesllm::apis::streaming_shapes::sse::SseStreamIter; - + let response_bytes = llm_response .bytes() .await .map_err(|e| ResponseError::StreamError(format!("Failed to read response: {}", e)))?; - + // Try to parse as SSE streaming response if let Ok(sse_iter) = SseStreamIter::try_from(response_bytes.as_ref()) { let mut accumulated_text = String::new(); - + for sse_event in sse_iter { // Skip [DONE] markers and event-only lines if sse_event.is_done() || sse_event.is_event_only() { continue; } - + // Try to get provider response and extract content delta if let Ok(provider_response) = sse_event.provider_response() { if let Some(content) = provider_response.content_delta() { @@ -149,14 +149,14 @@ impl ResponseHandler { } } } - + return Ok(accumulated_text); } - + // If not SSE, treat as regular text response let response_text = String::from_utf8(response_bytes.to_vec()) .map_err(|e| ResponseError::StreamError(format!("Failed to decode response: {}", e)))?; - + Ok(response_text) } } diff --git a/crates/brightstaff/src/router/mod.rs b/crates/brightstaff/src/router/mod.rs index d57273ec..9b1abbea 100644 --- a/crates/brightstaff/src/router/mod.rs +++ b/crates/brightstaff/src/router/mod.rs @@ -3,4 +3,4 @@ pub mod orchestrator_model; pub mod orchestrator_model_v1; pub mod plano_orchestrator; pub mod router_model; -pub mod router_model_v1; \ No newline at end of file +pub mod router_model_v1;