refactor(ocr): execute prepared request directly

This commit is contained in:
Yujong Lee 2026-09-15 10:37:08 -07:00
parent 9f13bf59b6
commit 3ef381a7b0
2 changed files with 12 additions and 6 deletions

View file

@ -44,6 +44,14 @@ pub async fn http_request(
request.send().await
}
#[tracing::instrument(target = "litellm::function_trace", level = "trace", skip_all)]
pub async fn execute_http_request(
client: &reqwest::Client,
request: reqwest::Request,
) -> Result<reqwest::Response, reqwest::Error> {
client.execute(request).await
}
pub fn truncate_error_body(body: &str) -> String {
if body.chars().count() <= UPSTREAM_ERROR_BODY_MAX_CHARS {
return body.to_string();

View file

@ -104,12 +104,10 @@ impl PreparedOcrCall {
pub(crate) async fn execute(self) -> Result<OcrProviderResponse, Error> {
let url = self.http.url().to_string();
let headers = request_headers(&self.http)?;
let response = crate::http_utils::http_request(reqwest::RequestBuilder::from_parts(
self.client.provider_http().clone(),
self.http,
))
.await
.map_err(super::client::transport_error)?;
let response =
crate::http_utils::execute_http_request(self.client.provider_http(), self.http)
.await
.map_err(super::client::transport_error)?;
let data = match self.request.config {
OcrConfigKind::Cohere => OcrProviderData::Cohere(
CohereParseConfig