lash_core/llm/
transport.rs1pub use lash_http_transport::retry_after_from_headers;
4pub use lash_sansio::llm::types::ProviderFailureKind;
6pub type ProviderFailure = lash_http_transport::HttpTransportError;
7pub type LlmTransportError = lash_http_transport::HttpTransportError;
8
9#[expect(
18 clippy::result_large_err,
19 reason = "provider transport errors are a public typed API and carry request/response diagnostics"
20)]
21pub fn validate_image_attachments(
22 req: &lash_sansio::llm::types::LlmRequest,
23 accepted_mimes: &[&str],
24 provider_name: &str,
25) -> Result<(), LlmTransportError> {
26 for (idx, att) in req.attachments.iter().enumerate() {
27 let mime = att.mime.trim().to_ascii_lowercase();
28 let normalized = if mime == "image/jpg" {
29 "image/jpeg"
30 } else {
31 mime.as_str()
32 };
33 if !accepted_mimes.contains(&normalized) {
34 return Err(ProviderFailure::new(format!(
35 "{provider_name} does not accept image attachments of type `{}` (attachment index {idx}); accepted: {}",
36 att.mime,
37 accepted_mimes.join(", "),
38 ))
39 .with_kind(ProviderFailureKind::Validation)
40 .with_code("unsupported_image_format"));
41 }
42 }
43 Ok(())
44}