mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(proxy): allow model instances in LiteLLM_EndUserTable validation * fix(proxy): preserve property-backed attributes when coercing spend * refactor(proxy): default null end-user spend with a field validator * fix(proxy): drop model-wide from_attributes from the end-user table * test(proxy): unskip the /customer/block integration contracts --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""
|
|
End-user table model.
|
|
|
|
Canonical definition for ``litellm_endusertable``. Re-exported from
|
|
``litellm.proxy._types`` for backwards compatibility.
|
|
"""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import ConfigDict, Field, field_validator
|
|
|
|
from litellm.models.budget import LiteLLM_BudgetTable
|
|
from litellm.models.object_permission import LiteLLM_ObjectPermissionTable
|
|
from litellm.types.llms.base import LiteLLMPydanticObjectBase
|
|
|
|
|
|
class LiteLLM_EndUserTable(LiteLLMPydanticObjectBase):
|
|
user_id: str
|
|
blocked: bool
|
|
alias: str | None = None
|
|
spend: float = 0.0
|
|
allowed_model_region: Literal["eu", "us"] | None = None
|
|
default_model: str | None = None
|
|
models: list[str] = Field(default_factory=list)
|
|
budget_id: str | None = None
|
|
litellm_budget_table: LiteLLM_BudgetTable | None = None
|
|
object_permission_id: str | None = None
|
|
object_permission: LiteLLM_ObjectPermissionTable | None = None
|
|
|
|
@field_validator("spend", mode="before")
|
|
@classmethod
|
|
def default_null_spend_to_zero(cls, spend: object) -> object:
|
|
return 0.0 if spend is None else spend
|
|
|
|
model_config = ConfigDict(protected_namespaces=())
|