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
(UI) Improvements to Add Team Model Flow (#8603)
Ishaan Jaff80243008250c
diff --git a/litellm/constants.py b/litellm/constants.pyindex 8d5cc2361a7..a1f7750d532 100644--- a/litellm/constants.py+++ b/litellm/constants.py@@ -425,3 +425,4 @@ BATCH_STATUS_POLL_MAX_ATTEMPTS = 24 # for 24 hoursHEALTH_CHECK_TIMEOUT_SECONDS = 60 # 60 secondsUI_SESSION_TOKEN_TEAM_ID = "litellm-dashboard"+LITELLM_PROXY_ADMIN_NAME = "default_user_id"diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.pyindex 9b4a9fa62c6..dbab85fbfc0 100644--- a/litellm/proxy/management_endpoints/model_management_endpoints.py+++ b/litellm/proxy/management_endpoints/model_management_endpoints.py@@ -11,26 +11,32 @@ model/{model_id}/update - PATCH endpoint for model update.#### MODEL MANAGEMENT ####import json+import uuidfrom typing import Optional, cast-from fastapi import APIRouter, Depends, HTTPException, status+from fastapi import APIRouter, Depends, HTTPException, Request, statusfrom pydantic import BaseModelfrom litellm._logging import verbose_proxy_logger+from litellm.constants import LITELLM_PROXY_ADMIN_NAMEfrom litellm.proxy._types import (CommonProxyErrors,+ LitellmUserRoles,PrismaCompatibleUpdateDBModel,ProxyErrorTypes,ProxyException,+ UpdateTeamRequest,UserAPIKeyAuth,)from litellm.proxy.auth.user_api_key_auth import user_api_key_authfrom litellm.proxy.common_utils.encrypt_decrypt_utils import encrypt_value_helper+from litellm.proxy.management_endpoints.team_endpoints import update_teamfrom litellm.proxy.utils import PrismaClientfrom litellm.types.router import (Deployment,DeploymentTypedDict,LiteLLMParamsTypedDict,+ ModelInfo,updateDeployment,)from litellm.utils import get_utc_datetime@@ -82,11 +88,16 @@ def update_db_model(# update model infoif updated_patch.model_info:+ _updated_model_info_dict = updated_patch.model_info.model_dump(+ exclude_unset=True+ )if "model_info" not in merged_deployment_dict:- merged_deployment_dict["model_info"] = {}- merged_deployment_dict["model_info"].update(- updated_patch.model_info.model_dump(exclude_none=True)+ merged_deployment_dict["model_info"] = ModelInfo()+ _original_model_info_dict = merged_deployment_dict["model_info"].model_dump(+ exclude_unset=True)+ _original_model_info_dict.update(_updated_model_info_dict)+ merged_deployment_dict["model_info"] = ModelInfo(**_original_model_info_dict)# convert to prisma compatible format@@ -206,3 +217,99 @@ async def patch_model(code=status.HTTP_500_INTERNAL_SERVER_ERROR,param=None,)+++################################# Helper Functions #################################+####################################################################################+####################################################################################+####################################################################################+++async def _add_model_to_db(+ model_params: Deployment,+ user_api_key_dict: UserAPIKeyAuth,+ prisma_client: PrismaClient,+):+ # encrypt litellm params #+ _litellm_params_dict = model_params.litellm_params.dict(exclude_none=True)+ _orignal_litellm_model_name = model_params.litellm_params.model+ for k, v in _litellm_params_dict.items():+ encrypted_value = encrypt_value_helper(value=v)+ model_params.litellm_params[k] = encrypted_value+ _data: dict = {+ "model_id": model_params.model_info.id,+ "model_name": model_params.model_name,+ "litellm_params": model_params.litellm_params.model_dump_json(exclude_none=True), # type: ignore+ "model_info": model_params.model_info.model_dump_json( # type: ignore+ exclude_none=True+ ),+ "created_by": user_api_key_dict.user_id or LITELLM_PROXY_ADMIN_NAME,+ "updated_by": user_api_key_dict.user_id or LITELLM_PROXY_ADMIN_NAME,+ }+ if model_params.model_info.id is not None:+ _data["model_id"] = model_params.model_info.id+ model_response = await prisma_client.db.litellm_proxymodeltable.create(+ data=_data # type: ignore+ )+ return model_response+++async def _add_team_model_to_db(+ model_params: Deployment,+ user_api_key_dict: UserAPIKeyAuth,+ prisma_client: PrismaClient,+):+ """+ If 'team_id' is provided,++ - generate a unique 'model_name' for the model (e.g. 'model_name_{team_id}_{uuid})+ - store the model in the db with the unique 'model_name'+ - store a team model alias mapping {"model_name": "model_name_{team_id}_{uuid}"}+ """+ _team_id = model_params.model_info.team_id+ if _team_id is None:+ return None+ original_model_name = model_params.model_name+ if original_model_name:+ model_params.model_info.team_public_model_name = original_model_name++ unique_model_name = f"model_name_{_team_id}_{uuid.uuid4()}"++ model_params.model_name = unique_model_name++ ## CREATE MODEL IN DB ##+ model_response = await _add_model_to_db(+ model_params=model_params,+ user_api_key_dict=user_api_key_dict,+ prisma_client=prisma_client,+ )++ ## CREATE MODEL ALIAS IN DB ##+ await update_team(+ data=UpdateTeamRequest(+ team_id=_team_id,+ model_aliases={original_model_name: unique_model_name},+ ),+ user_api_key_dict=user_api_key_dict,+ http_request=Request(scope={"type": "http"}),+ )++ return model_response+++def check_if_team_id_matches_key(+ team_id: Optional[str], user_api_key_dict: UserAPIKeyAuth+) -> bool:+ can_make_call = True+ if (+ user_api_key_dict.user_role+ and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN+ ):+ return True+ if team_id is None:+ if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:+ can_make_call = False+ else:+ if user_api_key_dict.team_id != team_id:+ can_make_call = False+ return can_make_calldiff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 8b0ccd309e9..421a588e390 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -107,6 +107,7 @@ import litellmfrom litellm import Routerfrom litellm._logging import verbose_proxy_logger, verbose_router_loggerfrom litellm.caching.caching import DualCache, RedisCache+from litellm.constants import LITELLM_PROXY_ADMIN_NAMEfrom litellm.exceptions import RejectedRequestErrorfrom litellm.integrations.SlackAlerting.slack_alerting import SlackAlertingfrom litellm.litellm_core_utils.core_helpers import (@@ -197,6 +198,11 @@ from litellm.proxy.management_endpoints.key_management_endpoints import (from litellm.proxy.management_endpoints.key_management_endpoints import (router as key_management_router,)+from litellm.proxy.management_endpoints.model_management_endpoints import (+ _add_model_to_db,+ _add_team_model_to_db,+ check_if_team_id_matches_key,+)from litellm.proxy.management_endpoints.model_management_endpoints import (router as model_management_router,)@@ -750,7 +756,7 @@ health_check_details = Nonehealth_check_results = {}queue: List = []litellm_proxy_budget_name = "litellm-proxy-budget"-litellm_proxy_admin_name = "default_user_id"+litellm_proxy_admin_name = LITELLM_PROXY_ADMIN_NAMEui_access_mode: Literal["admin", "all"] = "all"proxy_budget_rescheduler_min_time = 597proxy_budget_rescheduler_max_time = 605@@ -5837,97 +5843,6 @@ async def supported_openai_params(model: str):)-#### MODEL MANAGEMENT ####---async def _add_model_to_db(- model_params: Deployment,- user_api_key_dict: UserAPIKeyAuth,- prisma_client: PrismaClient,-):- # encrypt litellm params #- _litellm_params_dict = model_params.litellm_params.dict(exclude_none=True)- _orignal_litellm_model_name = model_params.litellm_params.model- for k, v in _litellm_params_dict.items():- encrypted_value = encrypt_value_helper(value=v)- model_params.litellm_params[k] = encrypted_value- _data: dict = {- "model_id": model_params.model_info.id,- "model_name": model_params.model_name,- "litellm_params": model_params.litellm_params.model_dump_json(exclude_none=True), # type: ignore- "model_info": model_params.model_info.model_dump_json( # type: ignore- exclude_none=True- ),- "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,- "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,- }- if model_params.model_info.id is not None:- _data["model_id"] = model_params.model_info.id- model_response = await prisma_client.db.litellm_proxymodeltable.create(- data=_data # type: ignore- )- return model_response---async def _add_team_model_to_db(- model_params: Deployment,- user_api_key_dict: UserAPIKeyAuth,- prisma_client: PrismaClient,-):- """- If 'team_id' is provided,-- - generate a unique 'model_name' for the model (e.g. 'model_name_{team_id}_{uuid})- - store the model in the db with the unique 'model_name'- - store a team model alias mapping {"model_name": "model_name_{team_id}_{uuid}"}- """- _team_id = model_params.model_info.team_id- original_model_name = model_params.model_name- if _team_id is None:- return None-- unique_model_name = f"model_name_{_team_id}_{uuid.uuid4()}"-- model_params.model_name = unique_model_name-- ## CREATE MODEL IN DB ##- model_response = await _add_model_to_db(- model_params=model_params,- user_api_key_dict=user_api_key_dict,- prisma_client=prisma_client,- )-- ## CREATE MODEL ALIAS IN DB ##- await update_team(- data=UpdateTeamRequest(- team_id=_team_id,- model_aliases={original_model_name: unique_model_name},- ),- user_api_key_dict=user_api_key_dict,- http_request=Request(scope={"type": "http"}),- )-- return model_response---def check_if_team_id_matches_key(- team_id: Optional[str], user_api_key_dict: UserAPIKeyAuth-) -> bool:- can_make_call = True- if (- user_api_key_dict.user_role- and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN- ):- return True- if team_id is None:- if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:- can_make_call = False- else:- if user_api_key_dict.team_id != team_id:- can_make_call = False- return can_make_call--#### [BETA] - This is a beta endpoint, format might change based on user feedback. - https://github.com/BerriAI/litellm/issues/964@router.post("/model/new",diff --git a/litellm/router.py b/litellm/router.pyindex c8ad151a55e..722eed56f1e 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -4910,9 +4910,21 @@ class Router:model_names = []for m in model_list:- model_names.append(m["model_name"])+ model_names.append(self._get_public_model_name(m))return model_names+ def _get_public_model_name(self, deployment: DeploymentTypedDict) -> str:+ """+ Returns the user-friendly model name for public display (e.g., on /models endpoint).++ Prioritizes the team's public model name if available, otherwise falls back to the default model name.+ """+ model_info = deployment.get("model_info")+ if model_info and model_info.get("team_public_model_name"):+ return model_info["team_public_model_name"]++ return deployment["model_name"]+def get_model_list_from_model_alias(self, model_name: Optional[str] = None) -> List[DeploymentTypedDict]:@@ -4993,14 +5005,16 @@ class Router:model_list = self.get_model_list(model_name=model_name)if model_list:for m in model_list:- for group in m.get("model_info", {}).get("access_groups", []):- if model_access_group is not None:- if group == model_access_group:+ _model_info = m.get("model_info")+ if _model_info:+ for group in _model_info.get("access_groups", []) or []:+ if model_access_group is not None:+ if group == model_access_group:+ model_name = m["model_name"]+ access_groups[group].append(model_name)+ else:model_name = m["model_name"]access_groups[group].append(model_name)- else:- model_name = m["model_name"]- access_groups[group].append(model_name)return access_groupsdiff --git a/litellm/router_strategy/budget_limiter.py b/litellm/router_strategy/budget_limiter.pyindex d584923ed58..3cb1bb965ab 100644--- a/litellm/router_strategy/budget_limiter.py+++ b/litellm/router_strategy/budget_limiter.py@@ -33,7 +33,12 @@ from litellm.router_utils.cooldown_callbacks import (_get_prometheus_logger_from_callbacks,)from litellm.types.llms.openai import AllMessageValues-from litellm.types.router import DeploymentTypedDict, LiteLLM_Params, RouterErrors+from litellm.types.router import (+ DeploymentTypedDict,+ LiteLLM_Params,+ ModelInfo,+ RouterErrors,+)from litellm.types.utils import BudgetConfigfrom litellm.types.utils import BudgetConfig as GenericBudgetInfofrom litellm.types.utils import GenericBudgetConfigType, StandardLoggingPayload@@ -766,7 +771,7 @@ class RouterBudgetLimiting(CustomLogger):returnfor _model in model_list:_litellm_params = _model.get("litellm_params", {})- _model_info = _model.get("model_info", {})+ _model_info: ModelInfo = _model.get("model_info") or ModelInfo()_model_id = _model_info.get("id")_max_budget = _litellm_params.get("max_budget")_budget_duration = _litellm_params.get("budget_duration")diff --git a/litellm/types/router.py b/litellm/types/router.pyindex 895cb6ee064..c1c802e538f 100644--- a/litellm/types/router.py+++ b/litellm/types/router.py@@ -107,7 +107,15 @@ class ModelInfo(BaseModel):None # specify if the base model is azure/gpt-3.5-turbo etc for accurate cost tracking)tier: Optional[Literal["free", "paid"]] = None- team_id: Optional[str] = None # the team id that this model belongs to++ """+ Team Model Specific Fields+ """+ # the team id that this model belongs to+ team_id: Optional[str] = None++ # the model_name that can be used by the team when making LLM calls+ team_public_model_name: Optional[str] = Nonedef __init__(self, id: Optional[Union[str, int]] = None, **params):if id is None:@@ -377,7 +385,7 @@ class LiteLLMParamsTypedDict(TypedDict, total=False):class DeploymentTypedDict(TypedDict, total=False):model_name: Required[str]litellm_params: Required[LiteLLMParamsTypedDict]- model_info: dict+ model_info: ModelInfoSPECIAL_MODEL_INFO_PARAMS = [diff --git a/tests/local_testing/test_add_update_models.py b/tests/local_testing/test_add_update_models.pyindex b3ad1f32f0d..4a04fcdf4a9 100644--- a/tests/local_testing/test_add_update_models.py+++ b/tests/local_testing/test_add_update_models.py@@ -1,5 +1,7 @@import sys, osimport traceback+import json+import uuidfrom dotenv import load_dotenvfrom fastapi import Requestfrom datetime import datetime@@ -17,6 +19,7 @@ import litellm, asynciofrom litellm.proxy.proxy_server import add_new_model, update_model, LitellmUserRolesfrom litellm._logging import verbose_proxy_loggerfrom litellm.proxy.utils import PrismaClient, ProxyLogging+from litellm.proxy.management_endpoints.team_endpoints import new_teamverbose_proxy_logger.setLevel(level=logging.DEBUG)from litellm.caching.caching import DualCache@@ -26,9 +29,7 @@ from litellm.router import ()from litellm.types.router import ModelInfo, updateDeployment, updateLiteLLMParams-from litellm.proxy._types import (- UserAPIKeyAuth,-)+from litellm.proxy._types import UserAPIKeyAuth, NewTeamRequest, LiteLLM_TeamTableproxy_logging_obj = ProxyLogging(user_api_key_cache=DualCache())@@ -234,3 +235,99 @@ async def test_add_update_model(prisma_client):assert _original_model.model_id == _new_model_in_db.model_idassert _original_model.model_name == _new_model_in_db.model_nameassert _original_model.model_info == _new_model_in_db.model_info+++async def _create_new_team(prisma_client):+ new_team_request = NewTeamRequest(+ team_alias=f"team_{uuid.uuid4().hex}",+ )+ _new_team = await new_team(+ data=new_team_request,+ user_api_key_dict=UserAPIKeyAuth(+ user_role=LitellmUserRoles.PROXY_ADMIN.value,+ api_key="sk-1234",+ user_id="1234",+ ),+ http_request=Request(+ scope={"type": "http", "method": "POST", "path": "/new_team"}+ ),+ )+ return LiteLLM_TeamTable(**_new_team)+++async def test_add_team_model_to_db(prisma_client):+ """+ Test adding a team model and verifying the team_public_model_name is stored correctly+ """+ setattr(litellm.proxy.proxy_server, "prisma_client", prisma_client)+ setattr(litellm.proxy.proxy_server, "master_key", "sk-1234")+ setattr(litellm.proxy.proxy_server, "store_model_in_db", True)++ await litellm.proxy.proxy_server.prisma_client.connect()++ from litellm.proxy.management_endpoints.model_management_endpoints import (+ _add_team_model_to_db,+ )+ import uuid++ new_team = await _create_new_team(prisma_client)+ team_id = new_team.team_id++ public_model_name = "my-gpt4-model"+ model_id = f"local-test-{uuid.uuid4().hex}"++ # Create test model deployment+ model_params = Deployment(+ model_name=public_model_name,+ litellm_params=LiteLLM_Params(+ model="gpt-4",+ api_key="test_api_key",+ ),+ model_info=ModelInfo(+ id=model_id,+ team_id=team_id,+ ),+ )++ # Add model to db+ model_response = await _add_team_model_to_db(+ model_params=model_params,+ user_api_key_dict=UserAPIKeyAuth(+ user_role=LitellmUserRoles.PROXY_ADMIN.value,+ api_key="sk-1234",+ user_id="1234",+ team_id=team_id,+ ),+ prisma_client=prisma_client,+ )++ # Verify model was created with correct attributes+ assert model_response is not None+ assert model_response.model_name.startswith(f"model_name_{team_id}")++ # Verify team_public_model_name was stored in model_info+ model_info = model_response.model_info+ assert model_info["team_public_model_name"] == public_model_name++ await asyncio.sleep(1)++ # Verify team model alias was created+ team = await prisma_client.db.litellm_teamtable.find_first(+ where={+ "team_id": team_id,+ },+ include={"litellm_model_table": True},+ )+ print("team=", team.model_dump_json())+ assert team is not None++ team_model = team.model_id+ print("team model id=", team_model)+ litellm_model_table = team.litellm_model_table+ print("litellm_model_table=", litellm_model_table.model_dump_json())+ model_aliases = litellm_model_table.model_aliases+ print("model_aliases=", model_aliases)++ assert public_model_name in model_aliases+ assert model_aliases[public_model_name] == model_response.model_namediff --git a/tests/local_testing/test_router.py b/tests/local_testing/test_router.pyindex fd4922fbb84..ce33ecc8f31 100644--- a/tests/local_testing/test_router.py+++ b/tests/local_testing/test_router.py@@ -2601,6 +2601,26 @@ def test_model_group_alias(hidden):assert len(model_names) == len(_model_list) + 1+def test_get_public_model_name():+ """+ Test that the _get_public_model_name helper returns the `team_public_model_name` if it exists, otherwise it returns the `model_name`.+ """+ _model_list = [+ {+ "model_name": "model_name_12299393939_gms",+ "litellm_params": {"model": "gpt-4o"},+ "model_info": {"team_public_model_name": "gpt-4o"},+ },+ ]+ router = Router(+ model_list=_model_list,+ )++ models = router.get_model_list()++ assert router._get_public_model_name(models[0]) == "gpt-4o"++# @pytest.mark.parametrize("on_error", [True, False])# @pytest.mark.asyncio# async def test_router_response_headers(on_error):diff --git a/ui/litellm-dashboard/src/components/add_model/add_model_tab.tsx b/ui/litellm-dashboard/src/components/add_model/add_model_tab.tsxindex 389ad0d4e24..d2c71ba908e 100644--- a/ui/litellm-dashboard/src/components/add_model/add_model_tab.tsx+++ b/ui/litellm-dashboard/src/components/add_model/add_model_tab.tsx@@ -115,6 +115,7 @@ const AddModelTab: React.FC<AddModelTabProps> = ({<AdvancedSettingsshowAdvancedSettings={showAdvancedSettings}setShowAdvancedSettings={setShowAdvancedSettings}+ teams={teams}/>diff --git a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsxindex 264968ceea1..a9229c8006c 100644--- a/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx+++ b/ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx@@ -14,7 +14,7 @@ const ConditionalPublicModelName: React.FC = () => {// Auto-populate model mappings when selected models changeuseEffect(() => {if (selectedModels.length > 0 && !selectedModels.includes('all-wildcard')) {- const mappings = selectedModels.map(model => ({+ const mappings = selectedModels.map((model: string) => ({public_name: model,litellm_model: model}));diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsxindex 00035652eeb..104663eda2d 100644--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx@@ -21,8 +21,11 @@ export const handleAddModelSubmit = async (formValues["model"] = wildcardModel;}- // Get model mappings+ // Get model mappings and safely remove from formValuesconst modelMappings = formValues["model_mappings"] || [];+ if ("model_mappings" in formValues) {+ delete formValues["model_mappings"];+ }// Create a deployment for each mappingfor (const mapping of modelMappings) {diff --git a/ui/litellm-dashboard/src/components/edit_model/edit_model_modal.tsx b/ui/litellm-dashboard/src/components/edit_model/edit_model_modal.tsxindex 5b5ecf3d8a9..7d71247784d 100644--- a/ui/litellm-dashboard/src/components/edit_model/edit_model_modal.tsx+++ b/ui/litellm-dashboard/src/components/edit_model/edit_model_modal.tsx@@ -2,6 +2,7 @@ import React from "react";import { Modal, Form, InputNumber, message } from "antd";import { TextInput } from "@tremor/react";import { Button as Button2 } from "antd";+import { modelUpdateCall } from "../networking";interface EditModelModalProps {visible: boolean;@@ -10,6 +11,61 @@ interface EditModelModalProps {onSubmit: (data: FormData) => void;}+export const handleEditModelSubmit = async (formValues: Record<string, any>, accessToken: string | null, setEditModalVisible: (visible: boolean) => void, setSelectedModel: (model: any) => void) => {+ // Call API to update team with teamId and values++ console.log("handleEditSubmit:", formValues);+ if (accessToken == null) {+ return;+ }++ let newLiteLLMParams: Record<string, any> = {};+ let model_info_model_id = null;++ if (formValues.input_cost_per_token) {+ // Convert from per 1M tokens to per token+ formValues.input_cost_per_token = Number(formValues.input_cost_per_token) / 1_000_000;+ }+ if (formValues.output_cost_per_token) {+ // Convert from per 1M tokens to per token+ formValues.output_cost_per_token = Number(formValues.output_cost_per_token) / 1_000_000;+ }+++ for (const [key, value] of Object.entries(formValues)) {+ if (key !== "model_id") {+ // Empty string means user wants to null the value+ newLiteLLMParams[key] = value === "" ? null : value;+ } else {+ model_info_model_id = value === "" ? null : value;+ }+ }++ let payload: {+ litellm_params: Record<string, any> | undefined;+ model_info: { id: any } | undefined;+ } = {+ litellm_params: Object.keys(newLiteLLMParams).length > 0 ? newLiteLLMParams : undefined,+ model_info: model_info_model_id !== undefined ? {+ id: model_info_model_id,+ } : undefined,+ };++ console.log("handleEditSubmit payload:", payload);++ try {+ let newModelValue = await modelUpdateCall(accessToken, payload);+ message.success(+ "Model updated successfully, restart server to see updates"+ );++ setEditModalVisible(false);+ setSelectedModel(null);+ } catch (error) {+ console.log(`Error occurred`);+ }+};+const EditModelModal: React.FC<EditModelModalProps> = ({visible,onCancel,diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsxindex b8074f2b816..bad0283da84 100644--- a/ui/litellm-dashboard/src/components/model_dashboard.tsx+++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx@@ -16,12 +16,15 @@ import {AccordionHeader,AccordionBody,} from "@tremor/react";++import ConditionalPublicModelName from "./add_model/conditional_public_model_name";import LiteLLMModelNameField from "./add_model/litellm_model_name";import AdvancedSettings from "./add_model/advanced_settings";import ProviderSpecificFields from "./add_model/provider_specific_fields";import { handleAddModelSubmit } from "./add_model/handle_add_model_submit";-import EditModelModal from "./edit_model/edit_model_modal";+import { getDisplayModelName } from "./view_model/model_name_display";+import EditModelModal, { handleEditModelSubmit } from "./edit_model/edit_model_modal";import {TabPanel,TabPanels,@@ -391,75 +394,11 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({setEditModalVisible(true);};- const handleInfoClick = (model: any) => {- setSelectedModel(model);- setInfoModalVisible(true);- };-const handleEditCancel = () => {setEditModalVisible(false);setSelectedModel(null);};- const handleInfoCancel = () => {- setInfoModalVisible(false);- setSelectedModel(null);- };-- const handleEditSubmit = async (formValues: Record<string, any>) => {- // Call API to update team with teamId and values-- console.log("handleEditSubmit:", formValues);- if (accessToken == null) {- return;- }-- let newLiteLLMParams: Record<string, any> = {};- let model_info_model_id = null;-- if (formValues.input_cost_per_token) {- // Convert from per 1M tokens to per token- formValues.input_cost_per_token = Number(formValues.input_cost_per_token) / 1_000_000;- }- if (formValues.output_cost_per_token) {- // Convert from per 1M tokens to per token- formValues.output_cost_per_token = Number(formValues.output_cost_per_token) / 1_000_000;- }--- for (const [key, value] of Object.entries(formValues)) {- if (key !== "model_id") {- // Empty string means user wants to null the value- newLiteLLMParams[key] = value === "" ? null : value;- } else {- model_info_model_id = value === "" ? null : value;- }- }-- let payload: {- litellm_params: Record<string, any> | undefined;- model_info: { id: any } | undefined;- } = {- litellm_params: Object.keys(newLiteLLMParams).length > 0 ? newLiteLLMParams : undefined,- model_info: model_info_model_id !== undefined ? {- id: model_info_model_id,- } : undefined,- };-- console.log("handleEditSubmit payload:", payload);-- try {- let newModelValue = await modelUpdateCall(accessToken, payload);- message.success(- "Model updated successfully, restart server to see updates"- );-- setEditModalVisible(false);- setSelectedModel(null);- } catch (error) {- console.log(`Error occurred`);- }- };const uploadProps: UploadProps = {name: "file",@@ -1162,23 +1101,23 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({<TableRow><TableHeaderCellstyle={{- maxWidth: "150px",+ maxWidth: "100px",whiteSpace: "normal",wordBreak: "break-word",fontSize: "11px",}}>- Public Model Name+ Model ID</TableHeaderCell><TableHeaderCellstyle={{- maxWidth: "100px",+ maxWidth: "150px",whiteSpace: "normal",wordBreak: "break-word",fontSize: "11px",}}>- Model ID+ Public Model Name</TableHeaderCell><TableHeaderCellstyle={{@@ -1319,15 +1258,6 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({key={index}style={{ maxHeight: "1px", minHeight: "1px" }}>- <TableCell- style={{- maxWidth: "100px",- whiteSpace: "normal",- wordBreak: "break-word",- }}- >- <p className="text-xs">{model.model_name || "-"}</p>- </TableCell><TableCellstyle={{maxWidth: "100px",@@ -1348,6 +1278,15 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({</Tooltip></div></TableCell>+ <TableCell+ style={{+ maxWidth: "100px",+ whiteSpace: "normal",+ wordBreak: "break-word",+ }}+ >+ <p className="text-xs">{getDisplayModelName(model) || "-"}</p>+ </TableCell><TableCellstyle={{maxWidth: "100px",@@ -1543,14 +1482,7 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({wordBreak: "break-word",}}>- <Grid numItems={3}>- <Col>- <Icon- icon={InformationCircleIcon}- size="sm"- onClick={() => handleInfoClick(model)}- />- </Col>+ <Grid numItems={2}><Col><Iconicon={PencilAltIcon}@@ -1578,7 +1510,7 @@ const ModelDashboard: React.FC<ModelDashboardProps> = ({visible={editModalVisible}onCancel={handleEditCancel}model={selectedModel}- onSubmit={handleEditSubmit}+ onSubmit={(data: FormData) => handleEditModelSubmit(data, accessToken, setEditModalVisible, setSelectedModel)}/></TabPanel><TabPanel className="h-full">diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsxindex ece453e0414..0c21da3fa43 100644--- a/ui/litellm-dashboard/src/components/model_info_view.tsx+++ b/ui/litellm-dashboard/src/components/model_info_view.tsx@@ -16,7 +16,9 @@ import { ArrowLeftIcon, TrashIcon } from "@heroicons/react/outline";import { modelDeleteCall, modelUpdateCall } from "./networking";import { Button, Form, Input, InputNumber, message, Select } from "antd";import EditModelModal from "./edit_model/edit_model_modal";+import { handleEditModelSubmit } from "./edit_model/edit_model_modal";import { getProviderLogoAndName } from "./provider_info_helpers";+import { getDisplayModelName } from "./view_model/model_name_display";interface ModelInfoViewProps {modelId: string;@@ -26,6 +28,8 @@ interface ModelInfoViewProps {userID: string | null;userRole: string | null;editModel: boolean;+ setEditModalVisible: (visible: boolean) => void;+ setSelectedModel: (model: any) => void;}export default function ModelInfoView({@@ -35,7 +39,9 @@ export default function ModelInfoView({accessToken,userID,userRole,- editModel+ editModel,+ setEditModalVisible,+ setSelectedModel}: ModelInfoViewProps) {const [isEditing, setIsEditing] = useState(false);const [form] = Form.useForm();@@ -47,7 +53,7 @@ export default function ModelInfoView({return (<div className="p-4"><Button- icon={ArrowLeftIcon}+ icon={<ArrowLeftIcon />}onClick={onClose}className="mb-4">@@ -70,39 +76,28 @@ export default function ModelInfoView({}};- const handleModelUpdate = async (values: any) => {- try {- if (!accessToken) return;-- let payload = {- litellm_params: Object.keys(values.litellm_params).length > 0 ? values.litellm_params : undefined,- model_info: values.model_info ? {- id: values.model_info.id,- } : undefined,- };-- await modelUpdateCall(accessToken, payload);- message.success("Model updated successfully");- setIsEditing(false);- } catch (error) {- console.error("Error updating model:", error);- message.error("Failed to update model");- }- };return (<div className="p-4"><div className="flex justify-between items-center mb-6"><div>- <Button onClick={onClose} className="mb-4">← Back</Button>- <Title>{modelData.model_name}</Title>+ <Button+ icon={<ArrowLeftIcon />}+ onClick={onClose}+ className="mb-4"+ >+ Back to Models+ </Button>+ <Title>Public Model Name: {getDisplayModelName(modelData)}</Title><Text className="text-gray-500 font-mono">{modelData.model_info.id}</Text></div>{canEditModel && (<div className="flex gap-2"><TremorButton+ icon={TrashIcon}+ variant="secondary"onClick={() => setIsDeleteModalOpen(true)}- color="red"+ className="flex items-center">Delete Model</TremorButton>@@ -165,6 +160,7 @@ export default function ModelInfoView({<Title>Model Settings</Title>{(canEditModel && !isEditing) && (<TremorButton+ variant="light"onClick={() => setIsEditing(true)}>Edit Settings@@ -177,7 +173,7 @@ export default function ModelInfoView({visible={isEditing}onCancel={() => setIsEditing(false)}model={modelData}- onSubmit={handleModelUpdate}+ onSubmit={(data: FormData) => handleEditModelSubmit(data, accessToken, setEditModalVisible, setSelectedModel)}/>) : (<div className="space-y-4">@@ -188,7 +184,7 @@ export default function ModelInfoView({<div><Text className="font-medium">Public Model Name</Text>- <div>{modelData.model_name}</div>+ <div>{getDisplayModelName(modelData)}</div></div><div>diff --git a/ui/litellm-dashboard/src/components/view_model/model_name_display.tsx b/ui/litellm-dashboard/src/components/view_model/model_name_display.tsxnew file mode 100644index 00000000000..6011d241bab--- /dev/null+++ b/ui/litellm-dashboard/src/components/view_model/model_name_display.tsx@@ -0,0 +1,15 @@+interface ModelNameDisplayProps {+ model: {+ model_name?: string;+ model_info?: {+ team_public_model_name?: string;+ };+ };+}++export const getDisplayModelName = (model: ModelNameDisplayProps['model']): string => {+if (model?.model_info?.team_public_model_name) {+ return model.model_info.team_public_model_name;+}+return model?.model_name || "-";+};\ No newline at end of file