mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
feat(model_dashboard.tsx): allow user to edit input cost per token for model on ui
also contains fixes for `/model/update`
This commit is contained in:
parent
1882ee1c4c
commit
b9ec7acb08
30 changed files with 145 additions and 133 deletions
|
@ -2567,6 +2567,38 @@ class Router:
|
|||
self.model_names.append(deployment.model_name)
|
||||
return deployment
|
||||
|
||||
def upsert_deployment(self, deployment: Deployment) -> Deployment:
|
||||
"""
|
||||
Add or update deployment
|
||||
Parameters:
|
||||
- deployment: Deployment - the deployment to be added to the Router
|
||||
|
||||
Returns:
|
||||
- The added/updated deployment
|
||||
"""
|
||||
# check if deployment already exists
|
||||
|
||||
if deployment.model_info.id in self.get_model_ids():
|
||||
# remove the previous deployment
|
||||
removal_idx: Optional[int] = None
|
||||
for idx, model in enumerate(self.model_list):
|
||||
if model["model_info"]["id"] == deployment.model_info.id:
|
||||
removal_idx = idx
|
||||
|
||||
if removal_idx is not None:
|
||||
self.model_list.pop(removal_idx)
|
||||
|
||||
# add to model list
|
||||
_deployment = deployment.to_json(exclude_none=True)
|
||||
self.model_list.append(_deployment)
|
||||
|
||||
# initialize client
|
||||
self._add_deployment(deployment=deployment)
|
||||
|
||||
# add to model names
|
||||
self.model_names.append(deployment.model_name)
|
||||
return deployment
|
||||
|
||||
def delete_deployment(self, id: str) -> Optional[Deployment]:
|
||||
"""
|
||||
Parameters:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue