mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
Add created_by
and updated_by
fields to Keys table (#8885)
* fix(proxy/_types.py): return created_by and updated_by on /key/list enables better trail of who made a key * fix(all_keys_table.tsx): add created by to key table allows easier tracking of who generated the key * fix(key_management_endpoints.py): track 'created_by' and 'updated_by' fields enable easier tracking of who created proxy keys
This commit is contained in:
parent
91cdc01149
commit
2d2d1b9df5
5 changed files with 25 additions and 1 deletions
|
@ -610,6 +610,8 @@ class GenerateKeyResponse(KeyRequestBase):
|
|||
token_id: Optional[str] = None
|
||||
litellm_budget_table: Optional[Any] = None
|
||||
token: Optional[str] = None
|
||||
created_by: Optional[str] = None
|
||||
updated_by: Optional[str] = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
|
@ -1387,7 +1389,9 @@ class LiteLLM_VerificationToken(LiteLLMPydanticObjectBase):
|
|||
litellm_budget_table: Optional[dict] = None
|
||||
org_id: Optional[str] = None # org id for a given key
|
||||
created_at: Optional[datetime] = None
|
||||
created_by: Optional[str] = None
|
||||
updated_at: Optional[datetime] = None
|
||||
updated_by: Optional[str] = None
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
|
|
@ -518,6 +518,10 @@ async def generate_key_fn( # noqa: PLR0915
|
|||
if "budget_duration" in data_json:
|
||||
data_json["key_budget_duration"] = data_json.pop("budget_duration", None)
|
||||
|
||||
if user_api_key_dict.user_id is not None:
|
||||
data_json["created_by"] = user_api_key_dict.user_id
|
||||
data_json["updated_by"] = user_api_key_dict.user_id
|
||||
|
||||
# Set tags on the new key
|
||||
if "tags" in data_json:
|
||||
from litellm.proxy.proxy_server import premium_user
|
||||
|
@ -1122,6 +1126,8 @@ async def generate_key_helper_fn( # noqa: PLR0915
|
|||
organization_id: Optional[str] = None,
|
||||
table_name: Optional[Literal["key", "user"]] = None,
|
||||
send_invite_email: Optional[bool] = None,
|
||||
created_by: Optional[str] = None,
|
||||
updated_by: Optional[str] = None,
|
||||
):
|
||||
from litellm.proxy.proxy_server import (
|
||||
litellm_proxy_budget_name,
|
||||
|
@ -1225,6 +1231,8 @@ async def generate_key_helper_fn( # noqa: PLR0915
|
|||
"model_max_budget": model_max_budget_json,
|
||||
"budget_id": budget_id,
|
||||
"blocked": blocked,
|
||||
"created_by": created_by,
|
||||
"updated_by": updated_by,
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
|
@ -161,7 +161,9 @@ model LiteLLM_VerificationToken {
|
|||
budget_id String?
|
||||
organization_id String?
|
||||
created_at DateTime? @default(now()) @map("created_at")
|
||||
created_by String?
|
||||
updated_at DateTime? @default(now()) @updatedAt @map("updated_at")
|
||||
updated_by String?
|
||||
litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
|
||||
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
|
||||
}
|
||||
|
|
|
@ -161,7 +161,9 @@ model LiteLLM_VerificationToken {
|
|||
budget_id String?
|
||||
organization_id String?
|
||||
created_at DateTime? @default(now()) @map("created_at")
|
||||
created_by String?
|
||||
updated_at DateTime? @default(now()) @updatedAt @map("updated_at")
|
||||
updated_by String?
|
||||
litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
|
||||
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
|
||||
}
|
||||
|
|
|
@ -224,13 +224,21 @@ export function AllKeysTable({
|
|||
},
|
||||
},
|
||||
{
|
||||
header: "Created",
|
||||
header: "Created At",
|
||||
accessorKey: "created_at",
|
||||
cell: (info) => {
|
||||
const value = info.getValue();
|
||||
return value ? new Date(value as string).toLocaleDateString() : "-";
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "Created By",
|
||||
accessorKey: "created_by",
|
||||
cell: (info) => {
|
||||
const value = info.getValue();
|
||||
return value ? value : "Unknown";
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "Expires",
|
||||
accessorKey: "expires",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue