mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
About 35,000 fixes ruff marks safe across 32 rules (UP006/UP045/UP007 modern annotations, UP032 f-strings, SIM114/SIM118, RET501, and friends), removal of the 1,296 typing imports the rewrite orphaned, and hand fixes for what the fixers could not see: five star-import freeloaders of typing names, two F823 late-import annotations, the /get/config/list introspection crash on types.UnionType, redundant function-local RoleMappings imports in ui_sso.py that shadowed the module-level name once the annotation lost its quotes, and one FURB168 tautology. B009/B010/PIE804/RUF019 are excluded on purpose: their safe fixes rewrite getattr/setattr/**-splat/key-in-dict escape hatches into forms basedpyright then rejects (283 new errors measured), so their budgets stay at base values. ruff-strict-budget.json drops by 39,579 this commit (39,968 across the branch) with 28 rules at an actual 0 and 9 more sharply down. type-discipline-budget.json ratchets LIT002/LIT006/LIT009 down; LIT001 moves to the now-honest total: the checker matches the spelling `set` but not the alias `Set`, so the 160 typing.Set annotations rewritten to set[...] were always mutable-set annotations and only now count.
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
"""
|
|
Proxy model table model.
|
|
|
|
Canonical definition for ``litellm_proxymodeltable``. Re-exported from
|
|
``litellm.proxy._types`` for backwards compatibility.
|
|
"""
|
|
|
|
import json
|
|
from datetime import datetime
|
|
|
|
from pydantic import ConfigDict, model_validator
|
|
|
|
from litellm.types.llms.base import LiteLLMPydanticObjectBase
|
|
|
|
|
|
class LiteLLM_ProxyModelTable(LiteLLMPydanticObjectBase):
|
|
model_id: str
|
|
model_name: str
|
|
litellm_params: dict
|
|
model_info: dict | None = None
|
|
blocked: bool = False
|
|
created_at: datetime | None = None
|
|
created_by: str | None = None
|
|
updated_at: datetime | None = None
|
|
updated_by: str | None = None
|
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
@model_validator(mode="before")
|
|
@classmethod
|
|
def check_potential_json_str(cls, values):
|
|
if isinstance(values.get("litellm_params"), str):
|
|
try:
|
|
values["litellm_params"] = json.loads(values["litellm_params"])
|
|
except json.JSONDecodeError:
|
|
pass
|
|
if isinstance(values.get("model_info"), str):
|
|
try:
|
|
values["model_info"] = json.loads(values["model_info"])
|
|
except json.JSONDecodeError:
|
|
pass
|
|
return values
|
|
|
|
@property
|
|
def is_blocked(self) -> bool:
|
|
return self.blocked
|
|
|
|
@property
|
|
def team_id(self) -> str | None:
|
|
if self.model_info:
|
|
return self.model_info.get("team_id")
|
|
return None
|
|
|
|
@property
|
|
def team_public_model_name(self) -> str | None:
|
|
if self.model_info:
|
|
return self.model_info.get("team_public_model_name")
|
|
return None
|