mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-23 11:53:08 -05:00
WIP Cleanup 🧹 Remove existing rate limiting logic Cleanup 🧼 Undo nit Cleanup 🧽 Move db constants (avoids circular import) WIP WIP Cleanup Lint Resolve alembic conflict Fix mypy Add backfill to migration Update comment Make unauthenticated users still adhere to global limits Use Depends Remove enum from table Update migration error handling + deletion Address verbal feedback, cleanup urls, minor nits
26 lines
631 B
Python
26 lines
631 B
Python
from pydantic import BaseModel
|
|
|
|
from danswer.db.models import TokenRateLimit
|
|
|
|
|
|
class TokenRateLimitArgs(BaseModel):
|
|
enabled: bool
|
|
token_budget: int
|
|
period_hours: int
|
|
|
|
|
|
class TokenRateLimitDisplay(BaseModel):
|
|
token_id: int
|
|
enabled: bool
|
|
token_budget: int
|
|
period_hours: int
|
|
|
|
@classmethod
|
|
def from_db(cls, token_rate_limit: TokenRateLimit) -> "TokenRateLimitDisplay":
|
|
return cls(
|
|
token_id=token_rate_limit.id,
|
|
enabled=token_rate_limit.enabled,
|
|
token_budget=token_rate_limit.token_budget,
|
|
period_hours=token_rate_limit.period_hours,
|
|
)
|