forked from phoenix/litellm-mirror
fix add key name + team name in alerting messages
This commit is contained in:
parent
24b9fbe19f
commit
6ff37aabb0
1 changed files with 27 additions and 0 deletions
|
@ -7914,6 +7914,11 @@ def exception_type(
|
||||||
if _vertex_location is not None:
|
if _vertex_location is not None:
|
||||||
extra_information += f"\nvertex_location: {_vertex_location}\n"
|
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
|
# End of Common Extra information Needed for all providers
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -11510,3 +11515,25 @@ def _get_base_model_from_metadata(model_call_details=None):
|
||||||
if base_model is not None:
|
if base_model is not None:
|
||||||
return base_model
|
return base_model
|
||||||
return None
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue