mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
feat: support parameterized ocr responses
This commit is contained in:
parent
60ce274ea7
commit
c8b0d0ff1e
1 changed files with 18 additions and 2 deletions
|
|
@ -27,14 +27,17 @@ pub enum OcrResponseHandling {
|
|||
pub trait OcrProviderConfig: Sync {
|
||||
fn supported_ocr_params(&self) -> &'static [&'static str];
|
||||
|
||||
fn map_ocr_params(&self, non_default_params: &Map<String, Value>) -> Map<String, Value> {
|
||||
fn map_ocr_params(
|
||||
&self,
|
||||
non_default_params: &Map<String, Value>,
|
||||
) -> Result<Map<String, Value>, Error> {
|
||||
let mut mapped_params = Map::new();
|
||||
for (param, value) in non_default_params {
|
||||
if self.supported_ocr_params().contains(¶m.as_str()) {
|
||||
mapped_params.insert(param.clone(), value.clone());
|
||||
}
|
||||
}
|
||||
mapped_params
|
||||
Ok(mapped_params)
|
||||
}
|
||||
|
||||
fn transform_ocr_request(
|
||||
|
|
@ -50,6 +53,15 @@ pub trait OcrProviderConfig: Sync {
|
|||
response_json: Value,
|
||||
) -> Result<OcrResponseData, Error>;
|
||||
|
||||
fn transform_ocr_response_with_params(
|
||||
&self,
|
||||
model: &str,
|
||||
response_json: Value,
|
||||
_optional_params: &Map<String, Value>,
|
||||
) -> Result<OcrResponseData, Error> {
|
||||
self.transform_ocr_response(model, response_json)
|
||||
}
|
||||
|
||||
fn complete_url(
|
||||
&self,
|
||||
api_base: Option<&str>,
|
||||
|
|
@ -68,6 +80,10 @@ pub trait OcrProviderConfig: Sync {
|
|||
OcrAuthStrategy::Bearer
|
||||
}
|
||||
|
||||
fn allows_bearer_auth_fallback(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn requires_data_uri_document(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue