mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
* refactor(rust): give Messages configs typed litellm params * feat(rust): port _normalize_system_role_messages for Messages hosts mid_conversation_system mirrors Python's module function for function: a leading run of system turns is hoisted into the top-level system, a later turn stays in place when the model map flags supports_mid_conversation_system and otherwise becomes a user turn where it was, never between a tool_use and its tool_result, and billing blocks are stripped from the hoisted system. The capability joins MessagesModelCapabilities and the bridge projection. Azure AI uses it in place of fold_system_role_messages, which hoisted every turn. * fix(rust): keep the Bedrock runtime endpoint behind a blank api_base * refactor(rust): import LitellmParams from its crate instead of a re-export * refactor(rust): template the Messages request decode errors Both decode failures go through ErrorDetail::invalid with the subject and the serde error as source instead of a preformatted sentence. * refactor(rust_bridge): read the module globals the param specs name The Messages host no longer keeps its own list of litellm globals; a spec whose spellings the call leaves out names the global to read, so the next family that has one needs no host change. * refactor(rust): give each route lookup Python's implicit None ProviderConfigManager's per-route methods list only the providers the route serves and fall through to None; the Rust lookups now do the same, so a new LlmProviders variant touches only the route that serves it.
45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
mod deployment;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use litellm_config::Model;
|
|
|
|
pub use deployment::Deployment;
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct Router(HashMap<String, Deployment>);
|
|
|
|
impl Router {
|
|
pub fn from_model_list(model_list: &[Model]) -> Self {
|
|
model_list
|
|
.iter()
|
|
.map(|model| {
|
|
(
|
|
model.model_name.clone(),
|
|
Deployment {
|
|
model: model.litellm_params.model.clone(),
|
|
api_key: model
|
|
.litellm_params
|
|
.api_key
|
|
.as_ref()
|
|
.map(|value| value.expose().to_string()),
|
|
api_base: model.litellm_params.api_base.clone(),
|
|
custom_llm_provider: model.litellm_params.custom_llm_provider.clone(),
|
|
litellm_params: model.litellm_params.clone(),
|
|
..Deployment::default()
|
|
},
|
|
)
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
pub fn get(&self, model_name: &str) -> Option<&Deployment> {
|
|
self.0.get(model_name)
|
|
}
|
|
}
|
|
|
|
impl FromIterator<(String, Deployment)> for Router {
|
|
fn from_iter<I: IntoIterator<Item = (String, Deployment)>>(entries: I) -> Self {
|
|
Self(entries.into_iter().collect())
|
|
}
|
|
}
|