From b137cea2309515db97a13dda2c67c8d202dad811 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 17 May 2024 17:45:05 -0700 Subject: [PATCH 1/2] fix(proxy_server.py): fix setting model id for db models get model_id and use that as it's id in router, this enables `/model/delete` to work with the given id from `/model/info` --- litellm/proxy/_super_secret_config.yaml | 4 ++-- litellm/proxy/proxy_server.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/_super_secret_config.yaml b/litellm/proxy/_super_secret_config.yaml index f73c36e49..f622fb147 100644 --- a/litellm/proxy/_super_secret_config.yaml +++ b/litellm/proxy/_super_secret_config.yaml @@ -14,5 +14,5 @@ model_list: router_settings: enable_pre_call_checks: true -general_settings: - master_key: sk-1234 # [OPTIONAL] Use to enforce auth on proxy. See - https://docs.litellm.ai/docs/proxy/virtual_keys +# general_settings: +# master_key: sk-1234 # [OPTIONAL] Use to enforce auth on proxy. See - https://docs.litellm.ai/docs/proxy/virtual_keys diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 08dd8c906..c7fa95c98 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2597,6 +2597,11 @@ class ProxyConfig: Return model info w/ id """ + _id: Optional[str] = getattr(model, "model_id", None) + if _id is not None: + model.model_info["id"] = _id + model.model_info["db_model"] = True + if model.model_info is not None and isinstance(model.model_info, dict): if "id" not in model.model_info: model.model_info["id"] = model.model_id From a75b865ebc3d580a51134b613ba611b455e072c0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 17 May 2024 22:00:44 -0700 Subject: [PATCH 2/2] test(test_config.py): fix test --- litellm/tests/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/tests/test_config.py b/litellm/tests/test_config.py index e38187e0e..47f632b96 100644 --- a/litellm/tests/test_config.py +++ b/litellm/tests/test_config.py @@ -102,7 +102,7 @@ async def test_delete_deployment(): pc = ProxyConfig() db_model = DBModel( - model_id="12340523", + model_id=deployment.model_info.id, model_name="gpt-3.5-turbo", litellm_params=encrypted_litellm_params, model_info={"id": deployment.model_info.id},