From be273b3c3b4f8fa02d6c2e28611570ed7ecf5b58 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 17 May 2024 16:07:02 -0700 Subject: [PATCH 1/2] fix - show correct base_model in slack alerts --- litellm/integrations/slack_alerting.py | 15 ++++++++++++--- litellm/proxy/proxy_server.py | 1 + litellm/types/router.py | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/litellm/integrations/slack_alerting.py b/litellm/integrations/slack_alerting.py index 015278c5572..f55a479efd4 100644 --- a/litellm/integrations/slack_alerting.py +++ b/litellm/integrations/slack_alerting.py @@ -671,11 +671,19 @@ class SlackAlerting(CustomLogger): ) await _cache.async_set_cache(key=message, value="SENT", ttl=2419200) return - return - async def model_added_alert(self, model_name: str, litellm_model_name: str): - model_info = litellm.model_cost.get(litellm_model_name, {}) + async def model_added_alert( + self, model_name: str, litellm_model_name: str, passed_model_info: Any + ): + base_model_from_user = getattr(passed_model_info, "base_model", None) + model_info = {} + base_model = "" + if base_model_from_user is not None: + model_info = litellm.model_cost.get(base_model_from_user, {}) + base_model = f"Base Model: `{base_model_from_user}`\n" + else: + model_info = litellm.model_cost.get(litellm_model_name, {}) model_info_str = "" for k, v in model_info.items(): if k == "input_cost_per_token" or k == "output_cost_per_token": @@ -687,6 +695,7 @@ class SlackAlerting(CustomLogger): message = f""" *🚅 New Model Added* Model Name: `{model_name}` +{base_model} Usage OpenAI Python SDK: ``` diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 763a53daf3e..f4ff58dcf04 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -8088,6 +8088,7 @@ async def add_new_model( await proxy_logging_obj.slack_alerting_instance.model_added_alert( model_name=model_params.model_name, litellm_model_name=_orignal_litellm_model_name, + passed_model_info=model_params.model_info, ) except: pass diff --git a/litellm/types/router.py b/litellm/types/router.py index 68ee387fea0..a61e551a70e 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -76,6 +76,9 @@ class ModelInfo(BaseModel): db_model: bool = ( False # used for proxy - to separate models which are stored in the db vs. config. ) + base_model: Optional[str] = ( + None # specify if the base model is azure/gpt-3.5-turbo etc for accurate cost tracking + ) def __init__(self, id: Optional[Union[str, int]] = None, **params): if id is None: From 04648ee368c9dd6d0e8d12484bded1bcbd485c76 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 17 May 2024 17:02:01 -0700 Subject: [PATCH 2/2] fix - enter base_model on azure --- .../src/components/model_dashboard.tsx | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 6e14fd0e0af..6bff680c87f 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -121,6 +121,7 @@ const handleSubmit = async (formValues: Record, accessToken: string // Iterate through the key-value pairs in formValues litellmParamsObj["model"] = litellm_model let modelName: string = ""; + console.log("formValues add deployment:", formValues); for (const [key, value] of Object.entries(formValues)) { if (value === '') { continue; @@ -1114,13 +1115,22 @@ const handleEditSubmit = async (formValues: Record) => { } { - selectedProvider == Providers.Azure && - - The actual model your azure deployment uses. Used for accurate cost tracking. Select name from here - + selectedProvider == Providers.Azure && + +
+ + + + + + The actual model your azure deployment uses. Used for accurate cost tracking. Select name from here + + +
} { selectedProvider == Providers.Bedrock &&