mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
Drop the core ocr() facade so VertexAuth and the http pool stay out of litellm-core's public API, move the http Error enum to error.rs, and inject the media DNS resolver into HttpClientPool instead of a per-call builder hook the cache key ignored. The bridge now reads litellm.* HTTP settings only through litellm/rust_bridge/settings.py, pinned by python_settings.json, while env overrides stay in Rust. This adds the Python default User-Agent, parses string ssl_verify globals like get_ssl_verify, drops per-call ssl_verify that Python OCR never honored, and removes the unused request_timeout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
80 lines
2.2 KiB
Rust
80 lines
2.2 KiB
Rust
mod credentials;
|
|
mod diagnostics;
|
|
mod errors;
|
|
mod http;
|
|
mod marshal;
|
|
mod python_settings;
|
|
mod routes;
|
|
mod token_counter;
|
|
|
|
#[pymodule(gil_used = true)]
|
|
mod _native {
|
|
#[cfg(feature = "panic-test")]
|
|
#[pymodule_export]
|
|
use crate::diagnostics::_panic_for_test;
|
|
#[pymodule_export]
|
|
use crate::diagnostics::gil_stats;
|
|
#[pymodule_export]
|
|
use crate::errors::{RustBridgeDeclined, RustUpstreamError};
|
|
#[pymodule_export]
|
|
use crate::routes::audio_transcription::{atranscription, transcription};
|
|
#[pymodule_export]
|
|
use crate::routes::chat_completions::{
|
|
achat_completions, chat_completions, chat_completions_decline,
|
|
};
|
|
#[pymodule_export]
|
|
use crate::routes::messages::{amessages, messages};
|
|
#[pymodule_export]
|
|
use crate::routes::ocr::{aocr, ocr};
|
|
#[pymodule_export]
|
|
use crate::routes::responses::ResponsesWebSocketConnection;
|
|
#[pymodule_export]
|
|
use crate::token_counter::TokenCounter;
|
|
}
|
|
|
|
use pyo3::prelude::*;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) fn native_module(py: Python<'_>) -> Bound<'_, PyModule> {
|
|
pyo3::wrap_pymodule!(_native)(py).into_bound(py)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn module_registration_preserves_the_public_surface() {
|
|
Python::initialize();
|
|
Python::attach(|py| {
|
|
let mut expected = vec![
|
|
"RustBridgeDeclined",
|
|
"RustUpstreamError",
|
|
"ocr",
|
|
"aocr",
|
|
"transcription",
|
|
"atranscription",
|
|
"messages",
|
|
"amessages",
|
|
"chat_completions_decline",
|
|
"chat_completions",
|
|
"achat_completions",
|
|
"ResponsesWebSocketConnection",
|
|
"TokenCounter",
|
|
"gil_stats",
|
|
];
|
|
expected.sort_unstable();
|
|
|
|
let mut public_names: Vec<String> = native_module(py)
|
|
.dict()
|
|
.keys()
|
|
.extract::<Vec<String>>()
|
|
.expect("module names should be strings")
|
|
.into_iter()
|
|
.filter(|name| !name.starts_with('_'))
|
|
.collect();
|
|
public_names.sort_unstable();
|
|
assert_eq!(public_names, expected);
|
|
});
|
|
}
|
|
}
|