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(python-bridge): derive NativeCall extraction (#45449)
yujongleeabee1c14e7df
diff --git a/litellm-rust/crates/python-bridge/src/routes/mod.rs b/litellm-rust/crates/python-bridge/src/routes/mod.rsindex 646b7799730..deb29f12bab 100644--- a/litellm-rust/crates/python-bridge/src/routes/mod.rs+++ b/litellm-rust/crates/python-bridge/src/routes/mod.rs@@ -16,24 +16,16 @@ use pyo3::{types::{PyDict, PyMapping, PyTuple},};+#[derive(FromPyObject)]pub(crate) struct NativeCall<'py> {+ #[pyo3(attribute)]args: Bound<'py, PyTuple>,+ #[pyo3(attribute, from_py_with = mapping_dict)]kwargs: Bound<'py, PyDict>,+ #[pyo3(attribute, from_py_with = mapping_dict)]bound: Bound<'py, PyDict>,}-impl<'py> FromPyObject<'_, 'py> for NativeCall<'py> {- type Error = PyErr;-- fn extract(call: Borrowed<'_, 'py, PyAny>) -> PyResult<Self> {- Ok(Self {- args: call.getattr("args")?.cast_into()?,- kwargs: mapping_dict(&call.getattr("kwargs")?)?,- bound: mapping_dict(&call.getattr("bound")?)?,- })- }-}-fn mapping_dict<'py>(value: &Bound<'py, PyAny>) -> PyResult<Bound<'py, PyDict>> {if let Ok(dict) = value.cast::<PyDict>() {return Ok(dict.clone());