diff --git a/litellm-rust/Cargo.lock b/litellm-rust/Cargo.lock index c968336a676..6ae8fe727dc 100644 --- a/litellm-rust/Cargo.lock +++ b/litellm-rust/Cargo.lock @@ -3838,6 +3838,7 @@ dependencies = [ "litellm-inference", "litellm-inference-chat", "litellm-inference-messages", + "litellm-inference-ocr", "litellm-inference-responses", "litellm-inference-transcription", "litellm-llms", @@ -4095,6 +4096,36 @@ dependencies = [ "wiremock", ] +[[package]] +name = "litellm-inference-ocr" +version = "0.1.0" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-util", + "litellm-auth", + "litellm-auth-aws", + "litellm-auth-gcp", + "litellm-core-utils", + "litellm-host", + "litellm-host-native", + "litellm-http", + "litellm-inference", + "litellm-llms", + "litellm-llms-types", + "litellm-secrets", + "litellm-tracing", + "mime_guess", + "rand 0.8.7", + "rstest", + "serde", + "serde_json", + "time", + "tokio", + "tracing", + "wiremock", +] + [[package]] name = "litellm-inference-responses" version = "0.1.0" @@ -4226,6 +4257,7 @@ dependencies = [ "litellm-inference", "litellm-inference-chat", "litellm-inference-messages", + "litellm-inference-ocr", "litellm-inference-responses", "litellm-inference-transcription", "litellm-llms", diff --git a/litellm-rust/Cargo.toml b/litellm-rust/Cargo.toml index c00e4816297..377cd8dd09f 100644 --- a/litellm-rust/Cargo.toml +++ b/litellm-rust/Cargo.toml @@ -21,6 +21,7 @@ litellm-inference-transcription = { path = "crates/inference-transcription" } litellm-inference-responses = { path = "crates/inference-responses" } litellm-inference-messages = { path = "crates/inference-messages" } litellm-inference-chat = { path = "crates/inference-chat" } +litellm-inference-ocr = { path = "crates/inference-ocr" } litellm-gateway-mcp = { path = "crates/gateway-mcp" } litellm-gateway = { path = "crates/gateway" } litellm-gateway-inference = { path = "crates/gateway-inference" } diff --git a/litellm-rust/crates/gateway-inference/Cargo.toml b/litellm-rust/crates/gateway-inference/Cargo.toml index f8ad3a86b2a..312d44b9a4b 100644 --- a/litellm-rust/crates/gateway-inference/Cargo.toml +++ b/litellm-rust/crates/gateway-inference/Cargo.toml @@ -17,6 +17,7 @@ litellm-inference-transcription.workspace = true litellm-inference-responses.workspace = true litellm-inference-messages.workspace = true litellm-inference-chat.workspace = true +litellm-inference-ocr.workspace = true litellm-host-http.workspace = true litellm-host.workspace = true litellm-http.workspace = true diff --git a/litellm-rust/crates/gateway-inference/src/lib.rs b/litellm-rust/crates/gateway-inference/src/lib.rs index 86ad15cacab..4663151f1de 100644 --- a/litellm-rust/crates/gateway-inference/src/lib.rs +++ b/litellm-rust/crates/gateway-inference/src/lib.rs @@ -16,9 +16,10 @@ use std::sync::Arc; use axum::{Router, routing::post}; use litellm_http::{ClientVariant, HttpClientConfig, media::UrlPolicy}; -use litellm_inference::{ocr::OcrRoute, resources::CoreResources}; +use litellm_inference::resources::CoreResources; use litellm_inference_chat::ChatCompletionsRoute; use litellm_inference_messages::MessagesRoute; +use litellm_inference_ocr::OcrRoute; use litellm_inference_responses::ResponsesRoute; use litellm_inference_transcription::AudioTranscriptionRoute; use litellm_llms::base_llm::ocr::{handler::OcrClient, settings::OcrSettings}; diff --git a/litellm-rust/crates/gateway-inference/src/ocr.rs b/litellm-rust/crates/gateway-inference/src/ocr.rs index e3bfc43089f..03d064b6bae 100644 --- a/litellm-rust/crates/gateway-inference/src/ocr.rs +++ b/litellm-rust/crates/gateway-inference/src/ocr.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use axum::{Json, extract::State, http::HeaderMap, response::IntoResponse}; use litellm_auth::SecretValue; -use litellm_inference::ocr::types::{LiteLLMOcrRequest, OcrConnectionInputs, OcrDocumentInput}; +use litellm_inference_ocr::types::{LiteLLMOcrRequest, OcrConnectionInputs, OcrDocumentInput}; use litellm_llms::base_llm::ocr::transformation::decode_request_value; use litellm_llms_types::formats::ocr::OcrDocument; use serde_json::Value; diff --git a/litellm-rust/crates/inference-ocr/Cargo.toml b/litellm-rust/crates/inference-ocr/Cargo.toml new file mode 100644 index 00000000000..0b8247637ee --- /dev/null +++ b/litellm-rust/crates/inference-ocr/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "litellm-inference-ocr" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] +base64.workspace = true +bytes.workspace = true +futures-util.workspace = true +litellm-auth = { workspace = true, features = ["aws", "azure", "gcp"] } +litellm-core-utils.workspace = true +litellm-host.workspace = true +litellm-http.workspace = true +litellm-inference.workspace = true +litellm-llms.workspace = true +litellm-llms-types.workspace = true +litellm-secrets.workspace = true +litellm-tracing.workspace = true +mime_guess = "2.0.5" +serde.workspace = true +serde_json = { workspace = true, features = ["preserve_order"] } +tokio.workspace = true +tracing.workspace = true + +[dev-dependencies] +litellm-auth-aws.workspace = true +litellm-auth-gcp.workspace = true +litellm-host-native.workspace = true +litellm-http = { workspace = true, features = ["test-support"] } +litellm-inference = { workspace = true, features = ["test-support"] } +rand.workspace = true +rstest.workspace = true +time.workspace = true +wiremock.workspace = true diff --git a/litellm-rust/crates/inference/src/ocr/arguments.rs b/litellm-rust/crates/inference-ocr/src/arguments.rs similarity index 100% rename from litellm-rust/crates/inference/src/ocr/arguments.rs rename to litellm-rust/crates/inference-ocr/src/arguments.rs diff --git a/litellm-rust/crates/inference/src/ocr/client.rs b/litellm-rust/crates/inference-ocr/src/client.rs similarity index 98% rename from litellm-rust/crates/inference/src/ocr/client.rs rename to litellm-rust/crates/inference-ocr/src/client.rs index c193d9174f7..21a4490048d 100644 --- a/litellm-rust/crates/inference/src/ocr/client.rs +++ b/litellm-rust/crates/inference-ocr/src/client.rs @@ -47,7 +47,7 @@ impl OcrRoute { interceptors: &impl Interceptors, observers: Option<&ObservationSender>, ) -> Result { - crate::diagnostic::unary(async { + litellm_inference::diagnostic::unary(async { let caller_document = matches!(&request.document, OcrDocumentInput::Document(_)); let prepared = prepare_request_document(request).await?; let execute: futures_util::future::BoxFuture<'_, Result> = diff --git a/litellm-rust/crates/inference/src/ocr/document.rs b/litellm-rust/crates/inference-ocr/src/document.rs similarity index 99% rename from litellm-rust/crates/inference/src/ocr/document.rs rename to litellm-rust/crates/inference-ocr/src/document.rs index 4be1eb932eb..ede0ef2a510 100644 --- a/litellm-rust/crates/inference/src/ocr/document.rs +++ b/litellm-rust/crates/inference-ocr/src/document.rs @@ -4,7 +4,7 @@ use base64::{Engine, engine::general_purpose::STANDARD}; use litellm_llms::base_llm::ocr::{error::Error, transformation::OCR_INLINE_MAX_BYTES}; use litellm_llms_types::formats::ocr::OcrDocument; -use crate::ocr::types::OcrDocumentInput; +use crate::types::OcrDocumentInput; pub fn prepare_document(input: OcrDocumentInput) -> Result { match input { diff --git a/litellm-rust/crates/inference/src/ocr/handler.rs b/litellm-rust/crates/inference-ocr/src/handler.rs similarity index 98% rename from litellm-rust/crates/inference/src/ocr/handler.rs rename to litellm-rust/crates/inference-ocr/src/handler.rs index 106b7162f2d..51b739f47ba 100644 --- a/litellm-rust/crates/inference/src/ocr/handler.rs +++ b/litellm-rust/crates/inference-ocr/src/handler.rs @@ -10,7 +10,7 @@ use litellm_llms_types::formats::ocr::LiteLLMOcrResponse; use serde_json::Value; use super::{arguments::is_secret_param, prepare::prepare_request, provider_config::OcrConfigKind}; -use crate::ocr::types::ResolvedOcrRequest; +use crate::types::ResolvedOcrRequest; pub(crate) async fn perform_ocr_request( client: &OcrClient, diff --git a/litellm-rust/crates/inference/src/ocr/mod.rs b/litellm-rust/crates/inference-ocr/src/lib.rs similarity index 100% rename from litellm-rust/crates/inference/src/ocr/mod.rs rename to litellm-rust/crates/inference-ocr/src/lib.rs diff --git a/litellm-rust/crates/inference/src/ocr/prepare.rs b/litellm-rust/crates/inference-ocr/src/prepare.rs similarity index 99% rename from litellm-rust/crates/inference/src/ocr/prepare.rs rename to litellm-rust/crates/inference-ocr/src/prepare.rs index 963ac81dd83..e3b0e819fb2 100644 --- a/litellm-rust/crates/inference/src/ocr/prepare.rs +++ b/litellm-rust/crates/inference-ocr/src/prepare.rs @@ -6,7 +6,7 @@ use litellm_llms::base_llm::ocr::{ }; use litellm_secrets::source::Secrets; -use crate::ocr::types::{LiteLLMOcrRequest, ResolvedOcrRequest}; +use crate::types::{LiteLLMOcrRequest, ResolvedOcrRequest}; pub(crate) fn prepare_request( request: ResolvedOcrRequest, @@ -95,7 +95,7 @@ mod tests { use serde_json::{Value, json}; use super::*; - use crate::ocr::{ + use crate::{ document::prepare_document, types::LiteLLMOcrRequest, wire::{OcrWireRequest, decode_request}, diff --git a/litellm-rust/crates/inference/src/ocr/provider_config.rs b/litellm-rust/crates/inference-ocr/src/provider_config.rs similarity index 100% rename from litellm-rust/crates/inference/src/ocr/provider_config.rs rename to litellm-rust/crates/inference-ocr/src/provider_config.rs diff --git a/litellm-rust/crates/inference/src/ocr/route.rs b/litellm-rust/crates/inference-ocr/src/route.rs similarity index 96% rename from litellm-rust/crates/inference/src/ocr/route.rs rename to litellm-rust/crates/inference-ocr/src/route.rs index f6f6533929c..85125452bda 100644 --- a/litellm-rust/crates/inference/src/ocr/route.rs +++ b/litellm-rust/crates/inference-ocr/src/route.rs @@ -9,7 +9,7 @@ use litellm_host::{ use litellm_llms::base_llm::ocr::error::Error; use litellm_llms_types::formats::ocr::LiteLLMOcrResponse; -use crate::ocr::types::{LiteLLMOcrRequest, OcrDocumentInput}; +use crate::types::{LiteLLMOcrRequest, OcrDocumentInput}; pub enum OcrOp { AcquireAzureAdToken(Reply), @@ -49,7 +49,7 @@ fn caller_token_provider(services: HostServices) -> TokenProviderHandle { }) } -impl crate::ocr::OcrRoute { +impl crate::OcrRoute { pub fn machine(self, request: OcrCall, observers: Option) -> OcrMachine { hosted_call( request, diff --git a/litellm-rust/crates/inference/src/ocr/types.rs b/litellm-rust/crates/inference-ocr/src/types.rs similarity index 100% rename from litellm-rust/crates/inference/src/ocr/types.rs rename to litellm-rust/crates/inference-ocr/src/types.rs diff --git a/litellm-rust/crates/inference/src/ocr/wire.rs b/litellm-rust/crates/inference-ocr/src/wire.rs similarity index 96% rename from litellm-rust/crates/inference/src/ocr/wire.rs rename to litellm-rust/crates/inference-ocr/src/wire.rs index ca83e26e3e7..a8f5a77a1cd 100644 --- a/litellm-rust/crates/inference/src/ocr/wire.rs +++ b/litellm-rust/crates/inference-ocr/src/wire.rs @@ -6,13 +6,13 @@ use litellm_llms_types::formats::ocr::OcrDocument; use serde::Deserialize; use serde_json::{Map, Value}; -use crate::ocr::types::{LiteLLMOcrRequest, OcrConnectionInputs, OcrDocumentInput}; +use crate::types::{LiteLLMOcrRequest, OcrConnectionInputs, OcrDocumentInput}; pub fn consumed_optional_params( model: &str, provider: Option<&str>, ) -> Result, Error> { - let specs = crate::ocr::arguments::consumed_optional_params(model, provider)?; + let specs = crate::arguments::consumed_optional_params(model, provider)?; Ok(consumed_optional_param_names(model, provider)? .into_iter() .map(|name| litellm_core_utils::call_arguments::ArgumentSpec { @@ -26,7 +26,7 @@ pub fn consumed_optional_param_names( model: &str, provider: Option<&str>, ) -> Result, Error> { - let names = crate::ocr::arguments::consumed_optional_param_names(model, provider)?; + let names = crate::arguments::consumed_optional_param_names(model, provider)?; let (_, config) = super::provider_config::resolve_provider_config(model, provider)?; if config == super::provider_config::OcrConfigKind::VertexDeepSeek { return Ok(names @@ -109,7 +109,7 @@ mod tests { use serde_json::json; use super::*; - use crate::ocr::arguments::is_supported_request; + use crate::arguments::is_supported_request; #[rstest] #[case::omitted(json!({"type":"document_url", "document_url":"https://example.com/a.pdf"}))] diff --git a/litellm-rust/crates/inference/tests/ocr/aws_textract.rs b/litellm-rust/crates/inference-ocr/tests/ocr/aws_textract.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/aws_textract.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/aws_textract.rs diff --git a/litellm-rust/crates/inference/tests/ocr/azure_ai.rs b/litellm-rust/crates/inference-ocr/tests/ocr/azure_ai.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/azure_ai.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/azure_ai.rs diff --git a/litellm-rust/crates/inference/tests/ocr/azure_document_intelligence.rs b/litellm-rust/crates/inference-ocr/tests/ocr/azure_document_intelligence.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/azure_document_intelligence.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/azure_document_intelligence.rs diff --git a/litellm-rust/crates/inference/tests/ocr/cohere.rs b/litellm-rust/crates/inference-ocr/tests/ocr/cohere.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/cohere.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/cohere.rs diff --git a/litellm-rust/crates/inference/tests/ocr/documents.rs b/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs similarity index 99% rename from litellm-rust/crates/inference/tests/ocr/documents.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/documents.rs index 439881d05ae..53731d17dce 100644 --- a/litellm-rust/crates/inference/tests/ocr/documents.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs @@ -1,7 +1,7 @@ use base64::Engine; use litellm_host::interceptors::WireRequest; -use litellm_inference::ocr::types::OcrDocumentInput; use litellm_inference::test_support::{http_config, no_secrets, resources}; +use litellm_inference_ocr::types::OcrDocumentInput; use rstest::rstest; use wiremock::{Mock, matchers::any}; diff --git a/litellm-rust/crates/inference/tests/ocr/lifecycle.rs b/litellm-rust/crates/inference-ocr/tests/ocr/lifecycle.rs similarity index 99% rename from litellm-rust/crates/inference/tests/ocr/lifecycle.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/lifecycle.rs index 171031e7ee5..d10a2e23c9a 100644 --- a/litellm-rust/crates/inference/tests/ocr/lifecycle.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/lifecycle.rs @@ -9,7 +9,7 @@ use litellm_host::{ interceptors::{RequestContext, WireRequest}, lifecycle::CallEvent, }; -use litellm_inference::ocr::{ +use litellm_inference_ocr::{ route::{Ocr, OcrCall, OcrOp}, types::OcrDocumentInput, }; diff --git a/litellm-rust/crates/inference/tests/ocr/machine.rs b/litellm-rust/crates/inference-ocr/tests/ocr/machine.rs similarity index 99% rename from litellm-rust/crates/inference/tests/ocr/machine.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/machine.rs index 8f7e08212ea..4f9266c4a8d 100644 --- a/litellm-rust/crates/inference/tests/ocr/machine.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/machine.rs @@ -12,7 +12,7 @@ use litellm_host::{ protocol::{HostRequest, InterceptRequest}, }; use litellm_host_native::services::HostCallHandler; -use litellm_inference::ocr::{ +use litellm_inference_ocr::{ route::{OcrCall, OcrMachine, OcrOp}, types::OcrDocumentInput, }; diff --git a/litellm-rust/crates/inference/tests/ocr/main.rs b/litellm-rust/crates/inference-ocr/tests/ocr/main.rs similarity index 99% rename from litellm-rust/crates/inference/tests/ocr/main.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/main.rs index e6c4b7483b5..436f11b24c9 100644 --- a/litellm-rust/crates/inference/tests/ocr/main.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/main.rs @@ -2,14 +2,14 @@ use litellm_host::{ interceptors::{RequestContext, WireRequest}, lifecycle::CallEvent, }; -use litellm_inference::ocr::{ +use litellm_inference::test_support::{http_config, no_secrets, resources}; +use litellm_inference_ocr::{ OcrRoute, document::prepare_document, route::{Ocr, OcrCall, OcrOp}, types::{LiteLLMOcrRequest, OcrDocumentInput}, wire::{OcrWireRequest, decode_request}, }; -use litellm_inference::test_support::{http_config, no_secrets, resources}; use litellm_llms::base_llm::ocr::{error::Error, settings::OcrSettings}; use litellm_llms_types::formats::ocr::{LiteLLMOcrResponse, OcrDocument}; use serde_json::{Map, Value, json}; diff --git a/litellm-rust/crates/inference/tests/ocr/mistral.rs b/litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/mistral.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs diff --git a/litellm-rust/crates/inference/tests/ocr/reducto.rs b/litellm-rust/crates/inference-ocr/tests/ocr/reducto.rs similarity index 100% rename from litellm-rust/crates/inference/tests/ocr/reducto.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/reducto.rs diff --git a/litellm-rust/crates/inference/tests/ocr/vertex_ai.rs b/litellm-rust/crates/inference-ocr/tests/ocr/vertex_ai.rs similarity index 98% rename from litellm-rust/crates/inference/tests/ocr/vertex_ai.rs rename to litellm-rust/crates/inference-ocr/tests/ocr/vertex_ai.rs index 9eb78377f7f..47ef3847d1f 100644 --- a/litellm-rust/crates/inference/tests/ocr/vertex_ai.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/vertex_ai.rs @@ -1,5 +1,5 @@ use litellm_auth::{InputSource, Sourced}; -use litellm_inference::ocr::arguments::is_supported_request; +use litellm_inference_ocr::arguments::is_supported_request; use litellm_llms::base_llm::ocr::settings::OcrSettings; use rstest::rstest; diff --git a/litellm-rust/crates/inference/tests/resources.rs b/litellm-rust/crates/inference-ocr/tests/resources.rs similarity index 97% rename from litellm-rust/crates/inference/tests/resources.rs rename to litellm-rust/crates/inference-ocr/tests/resources.rs index 61ff0656da7..1a9cc35db32 100644 --- a/litellm-rust/crates/inference/tests/resources.rs +++ b/litellm-rust/crates/inference-ocr/tests/resources.rs @@ -10,11 +10,9 @@ use litellm_auth_gcp::{ CredentialSource, VertexAuth, VertexAuthFuture, VertexProviderLoader, VertexTokenSource, }; use litellm_http::{HttpSettings, Resolution}; +use litellm_inference::resources::CoreResources; use litellm_inference::test_support::{RecordingSecrets, http_pool}; -use litellm_inference::{ - ocr::wire::{OcrWireRequest, decode_request}, - resources::CoreResources, -}; +use litellm_inference_ocr::wire::{OcrWireRequest, decode_request}; use litellm_llms::base_llm::ocr::settings::OcrSettings; use rstest::{fixture, rstest}; use serde_json::json; diff --git a/litellm-rust/crates/inference/tests/support/mod.rs b/litellm-rust/crates/inference-ocr/tests/support/mod.rs similarity index 99% rename from litellm-rust/crates/inference/tests/support/mod.rs rename to litellm-rust/crates/inference-ocr/tests/support/mod.rs index 3c89fb5940a..5b1b16bc483 100644 --- a/litellm-rust/crates/inference/tests/support/mod.rs +++ b/litellm-rust/crates/inference-ocr/tests/support/mod.rs @@ -22,8 +22,8 @@ pub fn build_ocr_route( url_policy: litellm_http::media::UrlPolicy, settings: litellm_llms::base_llm::ocr::settings::OcrSettings, secrets: Arc, -) -> litellm_inference::ocr::OcrRoute { - litellm_inference::ocr::OcrRoute::new( +) -> litellm_inference_ocr::OcrRoute { + litellm_inference_ocr::OcrRoute::new( litellm_llms::base_llm::ocr::handler::OcrClient::new( &resources.pool, config, diff --git a/litellm-rust/crates/inference/src/lib.rs b/litellm-rust/crates/inference/src/lib.rs index 9b4e80050c1..01787d3be08 100644 --- a/litellm-rust/crates/inference/src/lib.rs +++ b/litellm-rust/crates/inference/src/lib.rs @@ -4,7 +4,6 @@ pub mod diagnostic; pub mod caching; pub mod constants; pub mod error; -pub mod ocr; pub mod outbound; pub mod provider; pub mod resources; diff --git a/litellm-rust/crates/llms-types/AGENTS.md b/litellm-rust/crates/llms-types/AGENTS.md index 8590050283c..826aa009bec 100644 --- a/litellm-rust/crates/llms-types/AGENTS.md +++ b/litellm-rust/crates/llms-types/AGENTS.md @@ -1,4 +1,4 @@ -The same ownership rule applies to Messages, Responses, Chat Completions, OCR, and other API formats. This crate owns their shared API data contracts. Adapter contracts and shared transformation machinery belong in `llms/src/base_llm//`, provider policy in `llms/src///`, and call orchestration in `core/src//`. A provider originating a format, or several providers using a type, does not change these responsibilities. Existing model locations outside this crate are not exceptions to this rule for new shared API contracts +The same ownership rule applies to Messages, Responses, Chat Completions, OCR, and other API formats. This crate owns their shared API data contracts. Adapter contracts and shared transformation machinery belong in `llms/src/base_llm//`, provider policy in `llms/src///`, and call orchestration in `inference-`. A provider originating a format, or several providers using a type, does not change these responsibilities. Existing model locations outside this crate are not exceptions to this rule for new shared API contracts - `litellm-llms-types` owns shared API data contracts and their serialization - A type belongs here when it describes a request, response, event, or value that consumers must agree on independently of how a call executes diff --git a/litellm-rust/crates/llms/AGENTS.md b/litellm-rust/crates/llms/AGENTS.md index 91b81536fe7..e833652797a 100644 --- a/litellm-rust/crates/llms/AGENTS.md +++ b/litellm-rust/crates/llms/AGENTS.md @@ -1,4 +1,4 @@ -litellm-llms mirrors `litellm/llms/`: base config traits, provider transformations, and the OCR request handler in `base_llm/ocr/handler.rs`. Transport code (clients, media fetching, header helpers, transport errors) lives in `litellm-http`. See `../core/AGENTS.md` for how the crates layer. +litellm-llms mirrors `litellm/llms/`: base config traits, provider transformations, and the OCR request handler in `base_llm/ocr/handler.rs`. Transport code (clients, media fetching, header helpers, transport errors) lives in `litellm-http`. See `../inference/AGENTS.md` for how the crates layer. ## Python/Rust transformation pairs @@ -22,7 +22,7 @@ Azure Messages maps to `llms/azure_ai/anthropic/messages_transformation.py`; Bed ## Provider and format boundaries -The same ownership rule applies to Messages, Responses, Chat Completions, OCR, and other API formats. `litellm-llms-types` owns shared API data contracts. `llms/src/base_llm//` owns provider adapter contracts and shared transformation machinery. `llms/src///` owns provider implementations and policy. `core/src//` owns call orchestration. Repeating a format name identifies the API each layer handles, not duplicate ownership of its schema. These boundaries also apply between modules in the same crate +The same ownership rule applies to Messages, Responses, Chat Completions, OCR, and other API formats. `litellm-llms-types` owns shared API data contracts. `llms/src/base_llm//` owns provider adapter contracts and shared transformation machinery. `llms/src///` owns provider implementations and policy. `inference-` owns call orchestration. Repeating a format name identifies the API each layer handles, not duplicate ownership of its schema. These boundaries also apply between modules in the same crate A provider adapter may explicitly reuse another provider's transformation helper when that policy applies to its backend, such as Bedrock's Claude adapter using Anthropic payload shaping. Reuse across hosts of the same model family does not make the policy format-wide. Keep provider policy out of shared trait defaults and generic normalization, and keep shared execution contexts limited to inputs the adapter contract actually needs. Pure payload rewrites belong with transformations, not transport handlers diff --git a/litellm-rust/crates/python-bridge/Cargo.toml b/litellm-rust/crates/python-bridge/Cargo.toml index 79f695c9240..90fb43cd960 100644 --- a/litellm-rust/crates/python-bridge/Cargo.toml +++ b/litellm-rust/crates/python-bridge/Cargo.toml @@ -41,6 +41,7 @@ litellm-inference-transcription.workspace = true litellm-inference-responses.workspace = true litellm-inference-messages.workspace = true litellm-inference-chat.workspace = true +litellm-inference-ocr.workspace = true litellm-core-utils.workspace = true litellm-http.workspace = true litellm-llms.workspace = true diff --git a/litellm-rust/crates/python-bridge/src/routes/ocr/document.rs b/litellm-rust/crates/python-bridge/src/routes/ocr/document.rs index 866a1510f80..f85d7d4c7cb 100644 --- a/litellm-rust/crates/python-bridge/src/routes/ocr/document.rs +++ b/litellm-rust/crates/python-bridge/src/routes/ocr/document.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use litellm_host_python::{PythonFileReader, py_bytes}; -use litellm_inference::ocr::types::OcrDocumentInput; +use litellm_inference_ocr::types::OcrDocumentInput; use pyo3::{ exceptions::PyValueError, prelude::*, diff --git a/litellm-rust/crates/python-bridge/src/routes/ocr/host.rs b/litellm-rust/crates/python-bridge/src/routes/ocr/host.rs index a5ba3fc17ac..ed61b93a224 100644 --- a/litellm-rust/crates/python-bridge/src/routes/ocr/host.rs +++ b/litellm-rust/crates/python-bridge/src/routes/ocr/host.rs @@ -1,7 +1,7 @@ use litellm_auth::ResolvedCredential; use litellm_host_python::{InvokeError, PythonBinding, missing_state, to_py}; use litellm_host_python::{PythonHostCalls, PythonOwned}; -use litellm_inference::ocr::route::{Ocr, OcrCall, OcrOp}; +use litellm_inference_ocr::route::{Ocr, OcrCall, OcrOp}; use litellm_llms::base_llm::ocr::error::Error; use litellm_llms_types::formats::ocr::LiteLLMOcrResponse; use pyo3::{ diff --git a/litellm-rust/crates/python-bridge/src/routes/ocr/mod.rs b/litellm-rust/crates/python-bridge/src/routes/ocr/mod.rs index e77e2edc3b1..3b914c70c19 100644 --- a/litellm-rust/crates/python-bridge/src/routes/ocr/mod.rs +++ b/litellm-rust/crates/python-bridge/src/routes/ocr/mod.rs @@ -7,7 +7,7 @@ use host::OcrPythonHost; use litellm_callbacks_legacy_python::LoggingOperation; use litellm_core_utils::settings::ProcessEnvironment; use litellm_host_python::to_py; -use litellm_inference::ocr::provider_config; +use litellm_inference_ocr::provider_config; use litellm_llms::base_llm::ocr::settings::OcrSettings; use pyo3::{ prelude::*, @@ -58,7 +58,7 @@ fn run_ocr( crate::secrets::source(py)?, ) .map_err(http::client_error)?; - let route = litellm_inference::ocr::OcrRoute::new(client); + let route = litellm_inference_ocr::OcrRoute::new(client); Ok(route.machine(request, None)) }, OcrPythonHost::new(request.unbind()), diff --git a/litellm-rust/crates/python-bridge/src/routes/ocr/project.rs b/litellm-rust/crates/python-bridge/src/routes/ocr/project.rs index c60e0da96da..4bdc0b0119b 100644 --- a/litellm-rust/crates/python-bridge/src/routes/ocr/project.rs +++ b/litellm-rust/crates/python-bridge/src/routes/ocr/project.rs @@ -1,6 +1,6 @@ use litellm_auth::SecretValue; use litellm_host_python::from_py; -use litellm_inference::ocr::{ +use litellm_inference_ocr::{ types::{LiteLLMOcrRequest, OcrDocumentInput}, wire::{OcrWireRequest, consumed_optional_params, decode_document, decode_request_input}, };