feat(slack_alerting.py): refactor region outage alerting to do model based alerting instead

Unable to extract azure region from api base, makes sense to start with model alerting and then move to region
This commit is contained in:
Krrish Dholakia 2024-05-24 19:10:33 -07:00
parent a8fb4e33d5
commit 4536ed6f6e
7 changed files with 119 additions and 51 deletions

View file

@ -6286,7 +6286,9 @@ def get_model_region(
return None
def get_api_base(model: str, optional_params: dict) -> Optional[str]:
def get_api_base(
model: str, optional_params: Union[dict, LiteLLM_Params]
) -> Optional[str]:
"""
Returns the api base used for calling the model.
@ -6306,7 +6308,9 @@ def get_api_base(model: str, optional_params: dict) -> Optional[str]:
"""
try:
if "model" in optional_params:
if isinstance(optional_params, LiteLLM_Params):
_optional_params = optional_params
elif "model" in optional_params:
_optional_params = LiteLLM_Params(**optional_params)
else: # prevent needing to copy and pop the dict
_optional_params = LiteLLM_Params(
@ -6699,6 +6703,8 @@ def get_llm_provider(
Returns the provider for a given model name - e.g. 'azure/chatgpt-v-2' -> 'azure'
For router -> Can also give the whole litellm param dict -> this function will extract the relevant details
Raises Error - if unable to map model to a provider
"""
try:
## IF LITELLM PARAMS GIVEN ##