mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-11 03:12:55 +00:00
check_usage now checks the billable user's quota on every request, before the per-agent 24h limits, which keep applying to traffic through an agent. Until now a request without an agent key skipped every limit. A refusal is a 429 with Retry-After and a body naming the budget, usage, limit, the layer the limit came from and when it resets. Headless runs check the agent owner's quota before starting. A refused scheduled run is recorded as budget_exceeded; a refused webhook run returns a quota_exceeded result instead of raising, so Celery does not retry it.
26 lines
900 B
Python
26 lines
900 B
Python
"""Admin-set usage quotas.
|
|
|
|
Limits live in ``quota_policies`` at three layers (instance default, team
|
|
per-member allowance, user override), each with a token budget and a USD
|
|
budget. ``QuotaService`` resolves a user's effective limits and compares them
|
|
with their ``token_usage`` totals over the current ``QUOTA_PERIOD`` window.
|
|
"""
|
|
|
|
from docsgpt.quotas.providers import QuotaDefaultsProvider, register_defaults_provider
|
|
from docsgpt.quotas.resolver import ResolvedLimit, ResolvedLimits, resolve_limits
|
|
from docsgpt.quotas.service import BucketStatus, QuotaExceeded, QuotaExceededError, QuotaService
|
|
from docsgpt.quotas.windows import window_bounds
|
|
|
|
__all__ = [
|
|
"BucketStatus",
|
|
"QuotaDefaultsProvider",
|
|
"QuotaExceeded",
|
|
"QuotaExceededError",
|
|
"QuotaService",
|
|
"ResolvedLimit",
|
|
"ResolvedLimits",
|
|
"register_defaults_provider",
|
|
"resolve_limits",
|
|
"window_bounds",
|
|
]
|