mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
Add an aws_textract OCR provider on the Rust route, with no Python path. The detect-document-text model returns plain lines and analyze-document renders layout and tables as markdown. Both use Textract's synchronous API, so a multi-page PDF or TIFF is rejected with an error that names the single-page limit. A call with no region fails instead of falling back to Bedrock's default SigV4 covers the request body, and host hooks can rewrite that body before it is sent. litellm-http now has OutboundRequest, which serializes the body once, shows those bytes to a RequestSigner and is the only thing a route can send. Chat, audio transcription and OCR build it after their hooks ran, so a callback that redacts the body still produces a valid Bedrock or Textract signature ChatCompletionsAuth and AudioTranscriptionAuth are replaced by litellm_auth::RequestAuth, and one helper in core turns it into a signed or unsigned request. Audio transcription now signs only the AWS header set and rejects a forwarded header that SigV4 computes, the same as chat The OCR catalog routes aws_textract as Rust required, and the dispatch context reads the provider from the model prefix so a provider scoped rule can match
30 lines
992 B
Rust
30 lines
992 B
Rust
use std::time::Duration;
|
|
|
|
use litellm_auth::RequestAuth;
|
|
use litellm_auth_aws::SigV4Signer;
|
|
use litellm_http::outbound::OutboundRequest;
|
|
use serde_json::{Map, Value};
|
|
|
|
/// Header credentials are already in `headers`; SigV4 is applied here, over the
|
|
/// bytes that are sent.
|
|
pub(crate) async fn outbound_request<E>(
|
|
auth: &RequestAuth,
|
|
url: String,
|
|
headers: Vec<(String, String)>,
|
|
body: &Value,
|
|
timeout: Option<Duration>,
|
|
optional_params: &Map<String, Value>,
|
|
) -> Result<OutboundRequest, E>
|
|
where
|
|
E: From<litellm_http::Error> + From<litellm_auth_aws::Error>,
|
|
{
|
|
let RequestAuth::AwsSigV4 { region, service } = auth else {
|
|
return Ok(OutboundRequest::json(url, headers, body, timeout)?);
|
|
};
|
|
let env_lookup = |key: &str| std::env::var(key).ok();
|
|
let signer =
|
|
SigV4Signer::resolve(region.clone(), service, optional_params, &env_lookup).await?;
|
|
Ok(OutboundRequest::signed_json(
|
|
url, headers, body, timeout, &signer,
|
|
)?)
|
|
}
|