The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(rust): drop variable rebinding in s3 cache and bridge config
Yujong Lee58ffa8e4cea2
diff --git a/litellm-rust/crates/cache-s3/src/cache.rs b/litellm-rust/crates/cache-s3/src/cache.rsindex 88575f36fce..78e5f39dbcc 100644--- a/litellm-rust/crates/cache-s3/src/cache.rs+++ b/litellm-rust/crates/cache-s3/src/cache.rs@@ -42,16 +42,17 @@ pub struct S3Cache<C: CacheCodec> {impl<C: CacheCodec> S3Cache<C> {pub fn new(config: S3CacheConfig, codec: C, runtime: Handle) -> Self {- let mut builder = aws_sdk_s3::Config::builder()+ let endpoint_url: Option<String> = config.endpoint.map(|endpoint| endpoint.url);+ let base = aws_sdk_s3::Config::builder().behavior_version(BehaviorVersion::latest()).region(Region::new(config.region.clone())).credentials_provider(Credentials::new(config.auth)).request_checksum_calculation(RequestChecksumCalculation::WhenRequired).response_checksum_validation(ResponseChecksumValidation::WhenRequired);- let endpoint_url: Option<String> = config.endpoint.map(|endpoint| endpoint.url);- if let Some(url) = &endpoint_url {- builder = builder.endpoint_url(url).force_path_style(true);- }+ let builder = match &endpoint_url {+ Some(url) => base.endpoint_url(url).force_path_style(true),+ None => base,+ };Self {client: aws_sdk_s3::Client::from_conf(builder.build()),codec,diff --git a/litellm-rust/crates/python-bridge/src/cache/config.rs b/litellm-rust/crates/python-bridge/src/cache/config.rsindex 70d6f7c1841..269ddedfc0e 100644--- a/litellm-rust/crates/python-bridge/src/cache/config.rs+++ b/litellm-rust/crates/python-bridge/src/cache/config.rs@@ -642,14 +642,12 @@ fn optional_attribute_chain<'py>(value: &Bound<'py, PyAny>,names: &[&str],) -> PyResult<Option<Bound<'py, PyAny>>> {- let mut current = value.clone();- for name in names {- match optional_attribute(¤t, name)? {- Some(next) => current = next,- None => return Ok(None),- }- }- Ok(Some(current))+ names+ .iter()+ .try_fold(Some(value.clone()), |current, name| match current {+ Some(current) => optional_attribute(¤t, name),+ None => Ok(None),+ })}#[inline(never)]diff --git a/litellm/rust_bridge/_native.pyi b/litellm/rust_bridge/_native.pyiindex f1b010fb26e..6ad0e6be26e 100644--- a/litellm/rust_bridge/_native.pyi+++ b/litellm/rust_bridge/_native.pyi@@ -162,6 +162,7 @@ class _CacheTestHandle:*,ttl_seconds: float = 60.0,namespace: str | None = None,+ startup_nodes: Sequence[tuple[str, int]] | None = None,) -> _CacheTestHandle: ...@staticmethoddef s3(