mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(round 4 fixes) - Team model alias setting (#8474)
* update team info endpoint * clean up model alias * fix model alias * fix model alias card * clean up naming on docs * fix model alias card * fix _model_in_team_aliases * team alias - fix litellm.model_alias_map * fix _update_model_if_team_alias_exists * fix test_aview_spend_per_user * Test model alias functionality with teams: * complete e2e test * test_update_model_if_team_alias_exists
This commit is contained in:
parent
f1dd0f62b5
commit
81109893ec
4 changed files with 168 additions and 15 deletions
|
@ -635,6 +635,12 @@ async def add_litellm_data_to_request( # noqa: PLR0915
|
|||
user_api_key_dict=user_api_key_dict,
|
||||
)
|
||||
|
||||
# Team Model Aliases
|
||||
_update_model_if_team_alias_exists(
|
||||
data=data,
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
"[PROXY] returned data from litellm_pre_call_utils: %s", data
|
||||
)
|
||||
|
@ -664,6 +670,32 @@ async def add_litellm_data_to_request( # noqa: PLR0915
|
|||
return data
|
||||
|
||||
|
||||
def _update_model_if_team_alias_exists(
|
||||
data: dict,
|
||||
user_api_key_dict: UserAPIKeyAuth,
|
||||
) -> None:
|
||||
"""
|
||||
Update the model if the team alias exists
|
||||
|
||||
If a alias map has been set on a team, then we want to make the request with the model the team alias is pointing to
|
||||
|
||||
eg.
|
||||
- user calls `gpt-4o`
|
||||
- team.model_alias_map = {
|
||||
"gpt-4o": "gpt-4o-team-1"
|
||||
}
|
||||
- requested_model = "gpt-4o-team-1"
|
||||
"""
|
||||
_model = data.get("model")
|
||||
if (
|
||||
_model
|
||||
and user_api_key_dict.team_model_aliases
|
||||
and _model in user_api_key_dict.team_model_aliases
|
||||
):
|
||||
data["model"] = user_api_key_dict.team_model_aliases[_model]
|
||||
return
|
||||
|
||||
|
||||
def _get_enforced_params(
|
||||
general_settings: Optional[dict], user_api_key_dict: UserAPIKeyAuth
|
||||
) -> Optional[list]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue