diff --git a/crates/agentflare-store/src/documents.rs b/crates/agentflare-store/src/documents.rs index 86baa84a..57a8a0ee 100644 --- a/crates/agentflare-store/src/documents.rs +++ b/crates/agentflare-store/src/documents.rs @@ -550,8 +550,10 @@ impl Store { |row| { let blob: Vec = row.get(0)?; let vec: Vec = blob - .chunks_exact(4) - .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) + .as_chunks::<4>() + .0 + .iter() + .map(|c| f32::from_le_bytes(*c)) .collect(); Ok(vec) }, @@ -588,8 +590,10 @@ impl Store { return None; } let doc_vec: Vec = blob - .chunks_exact(4) - .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) + .as_chunks::<4>() + .0 + .iter() + .map(|c| f32::from_le_bytes(*c)) .collect(); let sim = crate::embed::cosine_similarity(query_vec, &doc_vec)? as f64; Some(( diff --git a/crates/agentflare-store/src/embed.rs b/crates/agentflare-store/src/embed.rs index d3944605..960912ed 100644 --- a/crates/agentflare-store/src/embed.rs +++ b/crates/agentflare-store/src/embed.rs @@ -25,8 +25,10 @@ pub fn bytes_to_vec(b: &[u8]) -> Option> { return None; } Some( - b.chunks_exact(4) - .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) + b.as_chunks::<4>() + .0 + .iter() + .map(|c| f32::from_le_bytes(*c)) .collect(), ) } diff --git a/crates/flare-proxy/src/forward.rs b/crates/flare-proxy/src/forward.rs index 8b5e57b7..0c620f28 100644 --- a/crates/flare-proxy/src/forward.rs +++ b/crates/flare-proxy/src/forward.rs @@ -125,7 +125,7 @@ async fn proxy_anthropic( let resp = match check_status(resp).await { Ok(resp) => resp, - Err(err) => return err, + Err(err) => return *err, }; Response::builder() @@ -170,7 +170,7 @@ async fn proxy_gemini( false, false, ), - Err(err) => err, + Err(err) => *err, } } @@ -212,7 +212,7 @@ async fn proxy_openai_compat( needs_heuristic, needs_think, ), - Err(err) => err, + Err(err) => *err, } } @@ -233,19 +233,25 @@ fn apply_extra_headers( /// Verify the upstream response succeeded, converting a non-2xx into an /// Anthropic-shaped error `Response`. On success, hands back the still-open /// `reqwest::Response` so the caller can stream its body. -async fn check_status(resp: reqwest::Response) -> Result { +/// +/// `Response` (`axum::http::Response`) is >=128 bytes, so +/// it's boxed in the `Err` variant rather than inflating every `Result` +/// return by that much even on the success path (`clippy::result_large_err`). +async fn check_status(resp: reqwest::Response) -> Result> { if resp.status().is_success() { return Ok(resp); } let status = resp.status(); let body = resp.text().await.unwrap_or_default(); let err_val: Value = serde_json::from_str(&body).unwrap_or(json!({"error": {"message": body}})); - Err(( - StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::BAD_GATEWAY), - [(axum::http::header::CONTENT_TYPE, "application/json")], - serde_json::to_string(&shape_xlat::error_to_anthropic(&err_val)).unwrap_or_default(), - ) - .into_response()) + Err(Box::new( + ( + StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::BAD_GATEWAY), + [(axum::http::header::CONTENT_TYPE, "application/json")], + serde_json::to_string(&shape_xlat::error_to_anthropic(&err_val)).unwrap_or_default(), + ) + .into_response(), + )) } /// Shared SSE loop for providers whose raw stream needs translating into