mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-05 01:59:27 +00:00
* refactor(proxy): inject database repositories through per-repository dependencies Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(proxy): model Prisma client cleanup * test(rust): include NativeDatabase in bridge API surface --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
from typing import Final, Literal, Protocol
|
|
|
|
from pydantic import ConfigDict, Field, model_validator
|
|
|
|
from litellm.types.llms.base import LiteLLMBaseModel
|
|
|
|
USER_BANNER_MAX_MESSAGE_LENGTH: Final = 4000
|
|
UserBannerSeverity = Literal["info", "warning", "error"]
|
|
|
|
|
|
class UserBannerUpdate(LiteLLMBaseModel):
|
|
model_config = ConfigDict(frozen=True)
|
|
|
|
enabled: bool = Field(
|
|
default=False,
|
|
description="If true, the banner is shown to all authenticated dashboard users.",
|
|
)
|
|
message: str = Field(
|
|
default="",
|
|
max_length=USER_BANNER_MAX_MESSAGE_LENGTH,
|
|
description="Banner text shown to dashboard users. Markdown is supported.",
|
|
)
|
|
severity: UserBannerSeverity = Field(
|
|
default="info",
|
|
description="Visual style of the banner.",
|
|
)
|
|
|
|
@model_validator(mode="after")
|
|
def _require_message_when_enabled(self) -> "UserBannerUpdate":
|
|
if self.enabled and not self.message.strip():
|
|
raise ValueError("message must be non-empty when the banner is enabled")
|
|
return self
|
|
|
|
|
|
class UserBanner(UserBannerUpdate):
|
|
revision: str = Field(
|
|
default="",
|
|
description=(
|
|
"Server-stamped opaque publish identity; a fresh value is generated on every "
|
|
"update so clients re-surface dismissed banners on republish."
|
|
),
|
|
)
|
|
|
|
|
|
class UserBannerStore(Protocol):
|
|
async def get_banner(self) -> UserBanner: ...
|
|
|
|
async def save_banner(self, banner: UserBanner) -> None: ...
|