fix pre-commit

This commit is contained in:
Adil Hafeez 2025-12-18 13:58:04 -08:00
parent 52a5fa2456
commit 34a8465721
No known key found for this signature in database
GPG key ID: 9B18EF7691369645
2 changed files with 10 additions and 10 deletions

View file

@ -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<String, ResponseError> {
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)
}
}

View file

@ -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;
pub mod router_model_v1;