mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
feat(rust-gateway): normalize OCR response model to requested alias
Echo the caller's requested model alias in the public OCR response instead of the deployment's provider model, matching the Python OCR proxy so the Axum route is a drop-in and does not surface the underlying provider model name. Also treat empty or whitespace-only deployment credentials as absent. Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
This commit is contained in:
parent
e55d2aae95
commit
90509c9acc
2 changed files with 18 additions and 6 deletions
|
|
@ -291,7 +291,7 @@ mod tests {
|
|||
assert_eq!(response.status(), reqwest::StatusCode::OK, "path {path}");
|
||||
let body: Value = response.json().await.expect("json body");
|
||||
assert_eq!(body["object"], "ocr", "path {path}");
|
||||
assert_eq!(body["model"], "mistral-ocr-latest", "path {path}");
|
||||
assert_eq!(body["model"], "rust-ocr-mistral", "path {path}");
|
||||
assert_eq!(body["pages"][0]["markdown"], "hello ocr", "path {path}");
|
||||
|
||||
let upstream_request = upstream_handle.await.expect("upstream served");
|
||||
|
|
|
|||
|
|
@ -35,17 +35,29 @@ pub async fn run_ocr(router: &Router, call: OcrCall) -> CoreResult<Value> {
|
|||
let params = &deployment.litellm_params;
|
||||
let (provider, provider_model) = split_provider(¶ms.model)?;
|
||||
|
||||
ocr(OcrRequest {
|
||||
let OcrCall {
|
||||
model: requested_model,
|
||||
document,
|
||||
optional_params,
|
||||
timeout,
|
||||
} = call;
|
||||
|
||||
let mut response = ocr(OcrRequest {
|
||||
model: provider_model,
|
||||
document: call.document,
|
||||
document,
|
||||
api_key: present(params.api_key.as_deref()),
|
||||
api_base: present(params.api_base.as_deref()),
|
||||
custom_llm_provider: provider,
|
||||
extra_headers: None,
|
||||
optional_params: call.optional_params,
|
||||
timeout: call.timeout,
|
||||
optional_params,
|
||||
timeout,
|
||||
})
|
||||
.await
|
||||
.await?;
|
||||
|
||||
if let Value::Object(map) = &mut response {
|
||||
map.insert("model".to_string(), Value::String(requested_model));
|
||||
}
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue