litellm/litellm-rust/crates/python-bridge/src/cache/mod.rs
devin-ai-integration[bot] 02d1e2c579
feat(cache): add a guarded native response-cache resolver foundation (#42769)
* feat(cache): resolve configured backend for native inference

* fix(cache): reuse the resolved native runtime only while its facade guard matches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(cache): decline native inference when the resolved runtime no longer matches its facade

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Yujong Lee <yujong@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-23 13:54:10 -07:00

39 lines
1.1 KiB
Rust

mod activation;
mod binding;
mod callback;
mod config;
mod embedder;
mod facade;
mod future;
mod handle;
mod identity;
mod native;
mod request;
mod resolver;
mod semantic;
use litellm_cache::Error;
use litellm_http::ClientVariant;
use pyo3::{
exceptions::{PyNotImplementedError, PyRuntimeError, PyValueError},
prelude::*,
types::PyDict,
};
pub(crate) use self::{binding::ResolvedCache, handle::CacheTestHandle, resolver::CacheResolver};
fn cache_error(error: Error) -> PyErr {
match error {
Error::InvalidEntry => PyValueError::new_err(error.to_string()),
Error::UnsupportedOperation => PyNotImplementedError::new_err(error.to_string()),
_ => PyRuntimeError::new_err(error.to_string()),
}
}
/// The host's pooled HTTP client, configured from the proxy's HTTP settings.
fn host_client(py: Python<'_>, variant: ClientVariant) -> PyResult<reqwest::Client> {
let http_config = crate::http::call_config(py, &PyDict::new(py), true)?;
crate::http::pool()
.client(&http_config, variant)
.map_err(crate::http::client_error)
}