mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
fix(types): keep the customer limit maps immutable so the type discipline gate stays level
This commit is contained in:
parent
4d5f1dd144
commit
b65073c3b9
2 changed files with 5 additions and 4 deletions
|
|
@ -13,7 +13,7 @@ from typing import (
|
|||
Literal,
|
||||
Protocol,
|
||||
TypeAlias,
|
||||
cast, # noqa: TID251 # cast-ok: key metadata is an untyped JSON blob, narrowed by TypeAdapter right after
|
||||
cast, # noqa: TID251 # narrows the untyped key metadata blob in _key_customer_limit_map
|
||||
)
|
||||
|
||||
from fastapi import HTTPException, Request, status
|
||||
|
|
@ -1651,7 +1651,7 @@ def get_key_tag_rpm_limit(
|
|||
return None
|
||||
|
||||
|
||||
_CUSTOMER_LIMIT_MAP: Final[TypeAdapter[dict[str, int]]] = TypeAdapter(dict[str, int])
|
||||
_CUSTOMER_LIMIT_MAP: Final[TypeAdapter[Mapping[str, int]]] = TypeAdapter(Mapping[str, int])
|
||||
|
||||
|
||||
def _key_customer_limit_map(user_api_key_dict: UserAPIKeyAuth, field: str) -> Mapping[str, int]:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any # noqa: TID251 # metadata and models stay Any so existing callers keep type-checking
|
||||
|
||||
from pydantic import ConfigDict, NonNegativeInt, field_validator
|
||||
|
|
@ -52,8 +53,8 @@ class GenerateRequestBase(LiteLLMPydanticObjectBase):
|
|||
model_tpm_limit: dict[object, object] | None = None
|
||||
mcp_rpm_limit: dict[str, int] | None = None
|
||||
tag_rpm_limit: dict[str, int] | None = None
|
||||
customer_rpm_limit: dict[str, NonNegativeInt] | None = None
|
||||
customer_tpm_limit: dict[str, NonNegativeInt] | None = None
|
||||
customer_rpm_limit: Mapping[str, NonNegativeInt] | None = None
|
||||
customer_tpm_limit: Mapping[str, NonNegativeInt] | None = None
|
||||
guardrails: list[str] | None = None
|
||||
policies: list[str] | None = None
|
||||
prompts: list[str] | None = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue