mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
feat - audit logs
This commit is contained in:
parent
b7a9eed17c
commit
78e1f1659b
2 changed files with 46 additions and 0 deletions
|
@ -76,6 +76,16 @@ class LitellmUserRoles(str, enum.Enum):
|
||||||
return ui_labels.get(self.value, "")
|
return ui_labels.get(self.value, "")
|
||||||
|
|
||||||
|
|
||||||
|
class LitellmTableNames(str, enum.Enum):
|
||||||
|
"""
|
||||||
|
Enum for Table Names used by LiteLLM
|
||||||
|
"""
|
||||||
|
|
||||||
|
TEAM_TABLE_NAME: str = "LiteLLM_TeamTable"
|
||||||
|
USER_TABLE_NAME: str = "LiteLLM_UserTable"
|
||||||
|
PROXY_MODEL_TABLE_NAME: str = "LiteLLM_ModelTable"
|
||||||
|
|
||||||
|
|
||||||
AlertType = Literal[
|
AlertType = Literal[
|
||||||
"llm_exceptions",
|
"llm_exceptions",
|
||||||
"llm_too_slow",
|
"llm_too_slow",
|
||||||
|
|
|
@ -10363,6 +10363,42 @@ async def new_team(
|
||||||
return team_row.dict()
|
return team_row.dict()
|
||||||
|
|
||||||
|
|
||||||
|
async def create_audit_log_for_update(
|
||||||
|
action: Literal["create", "update", "delete"],
|
||||||
|
# fyi: pylint does not directly allow you to pass Literal["LiteLLM_TeamTable"]
|
||||||
|
# because LiteLLM_TeamTable is also defined in _types.py
|
||||||
|
table_name: Literal[
|
||||||
|
LitellmTableNames.TEAM_TABLE_NAME,
|
||||||
|
LitellmTableNames.USER_TABLE_NAME,
|
||||||
|
LitellmTableNames.PROXY_MODEL_TABLE_NAME,
|
||||||
|
],
|
||||||
|
object_id: str,
|
||||||
|
changed_by: str,
|
||||||
|
before_value: dict,
|
||||||
|
after_value: dict,
|
||||||
|
):
|
||||||
|
if not premium_user:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
# [Non-Blocking Exception. Do not allow blocking LLM API call]
|
||||||
|
verbose_proxy_logger.error(f"Failed Creating audit log {e}")
|
||||||
|
|
||||||
|
# await prisma_client.create_audit_log(
|
||||||
|
# data={
|
||||||
|
# "action": action,
|
||||||
|
# "object_id": object_id,
|
||||||
|
# "changed_by": changed_by,
|
||||||
|
# "before_value": json.dumps(before_value),
|
||||||
|
# "after_value": json.dumps(after_value),
|
||||||
|
# }
|
||||||
|
# )
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/team/update", tags=["team management"], dependencies=[Depends(user_api_key_auth)]
|
"/team/update", tags=["team management"], dependencies=[Depends(user_api_key_auth)]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue