mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
refactor(proxy): build LiteLLM_TeamTable via model_validate at **dict sites
Adding max_tokens_budget and tokens_used to LiteLLM_TeamTable made the existing LiteLLM_TeamTable(**dict) constructions each flag two more basedpyright unknown-argument / argument-type errors, which the type-check ratchet forbids. model_validate takes the untyped dict as a single validated argument, so no per-field diagnostics fire. It is also the correct pydantic v2 way to build a model from a dict, and it leaves these call sites below their merge-base count.
This commit is contained in:
parent
fe6edbef4c
commit
dc088d9813
3 changed files with 7 additions and 8 deletions
|
|
@ -165,7 +165,7 @@ class ScimTransformations:
|
|||
raise HTTPException(status_code=500, detail={"error": "No database connected"})
|
||||
|
||||
if isinstance(team, dict):
|
||||
team = LiteLLM_TeamTable(**team)
|
||||
team = LiteLLM_TeamTable.model_validate(team)
|
||||
|
||||
# Get team members with proper display names
|
||||
scim_members: Final[list[SCIMMember]] = []
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ async def add_team_callbacks(
|
|||
# authenticated key holder could overwrite another team's logging
|
||||
# config (and read back the credentials they wrote).
|
||||
if not await get_team_access().allows(
|
||||
user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
):
|
||||
team_access_denied()
|
||||
|
||||
|
|
@ -516,7 +516,7 @@ async def delete_team_callback(
|
|||
# deregister its callbacks, otherwise any authenticated key holder could
|
||||
# silence another team's observability integration.
|
||||
if not await get_team_access().allows(
|
||||
user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
):
|
||||
team_access_denied()
|
||||
|
||||
|
|
@ -649,7 +649,7 @@ async def disable_team_logging(
|
|||
# team may disable its logging — otherwise any authenticated key
|
||||
# holder can silence audit logging for any team.
|
||||
if not await get_team_access().allows(
|
||||
user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
):
|
||||
team_access_denied()
|
||||
|
||||
|
|
@ -790,7 +790,7 @@ async def get_team_callbacks(
|
|||
# (Langfuse / Langsmith / GCS). Only proxy admins / org admins /
|
||||
# team admins of THIS team may read them.
|
||||
if not await get_team_access().allows(
|
||||
user_api_key_dict, LiteLLM_TeamTable(**_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
user_api_key_dict, LiteLLM_TeamTable.model_validate(_existing_team.model_dump()), TEAM_OR_ORG_ADMIN
|
||||
):
|
||||
team_access_denied()
|
||||
|
||||
|
|
|
|||
|
|
@ -1769,9 +1769,8 @@ async def new_team(
|
|||
)
|
||||
|
||||
## ADD TO TEAM TABLE
|
||||
complete_team_data: Final = LiteLLM_TeamTable(
|
||||
**data_json,
|
||||
model_id=_model_id,
|
||||
complete_team_data: Final = LiteLLM_TeamTable.model_validate(
|
||||
{**data_json, "model_id": _model_id},
|
||||
)
|
||||
|
||||
# Set Management Endpoint Metadata Fields
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue