Skip to content

Commit

Permalink
fix add key name + team name in alerting messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan-jaff committed May 6, 2024
1 parent 24b9fbe commit 6ff37aa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions litellm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7914,6 +7914,11 @@ def exception_type(
if _vertex_location is not None:
extra_information += f"\nvertex_location: {_vertex_location}\n"

# on litellm proxy add key name + team to exceptions
extra_information = _add_key_name_and_team_to_alert(
request_info=extra_information, metadata=_metadata
)

################################################################################
# End of Common Extra information Needed for all providers
################################################################################
Expand Down Expand Up @@ -11510,3 +11515,25 @@ def _get_base_model_from_metadata(model_call_details=None):
if base_model is not None:
return base_model
return None


def _add_key_name_and_team_to_alert(request_info: str, metadata: dict) -> str:
"""
Internal helper function for litellm proxy
Add the Key Name + Team Name to the error
Only gets added if the metadata contains the user_api_key_alias and user_api_key_team_alias
[Non-Blocking helper function]
"""
try:
_api_key_name = metadata.get("user_api_key_alias", "")
_user_api_key_team_alias = metadata.get("user_api_key_team_alias", "")
if _api_key_name is not None:
request_info = (
f"\n\nKey Name: `{_api_key_name}`\nTeam: `{_user_api_key_team_alias}`"
+ request_info
)

return request_info
except:
return request_info

0 comments on commit 6ff37aa

Please sign in to comment.