From 66bc0fc3433b11fcdaccf945917df25eb2aadbd3 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Wed, 29 Nov 2023 16:08:38 -0800 Subject: [PATCH] (fix) proxy: /health works with router updates --- litellm/proxy/proxy_server.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 335205eca2..6da78c2763 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -914,13 +914,25 @@ async def health_endpoint(request: Request, model: Optional[str] = fastapi.Query litellm_params = model_name["litellm_params"] if litellm_params["model"] not in litellm.all_embedding_models: # filter out embedding models litellm_params["messages"] = [{"role": "user", "content": "Hey, how's it going?"}] + ########## remove -ModelID-XXXX from model ############## + original_model_string = litellm_params["model"] + # Find the index of "ModelID" in the string + index_of_model_id = original_model_string.find("-ModelID") + # Remove everything after "-ModelID" if it exists + if index_of_model_id != -1: + litellm_params["model"] = original_model_string[:index_of_model_id] + else: + litellm_params["model"] = original_model_string + litellm_params.pop("tpm", None) + litellm_params.pop("rpm", None) litellm.completion(**litellm_params) cleaned_params = {} for key in litellm_params: if key != "api_key" and key != "messages": cleaned_params[key] = litellm_params[key] healthy_endpoints.append(cleaned_params) - except: + except Exception as e: + print("Got Exception", e) cleaned_params = {} for key in litellm_params: if key != "api_key" and key != "messages":