mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-13 12:14:00 +00:00
- check_usage treats a request through a keyless (draft) agent as agent traffic, matching how its usage rows are bucketed and the headless rule - dashboard edits carry the stored enabled flag instead of re-enabling the policy; disabled policies are labelled in the Quotas tab and the editor - quota 429s send x-should-retry: false so OpenAI SDK clients do not retry a refusal that cannot succeed before the reset - cached-input and cache-write rates for Anthropic, OpenRouter and Groq gpt-oss-120b; refresh OpenRouter deepseek-v3.2 list prices - UsageQuota reuses usagePercent; docs note that a user override needs an existing user
17 lines
629 B
Python
17 lines
629 B
Python
"""HTTP rendering of a quota refusal."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from flask import Response, jsonify, make_response
|
|
|
|
from docsgpt.quotas.service import QuotaExceeded
|
|
|
|
|
|
def quota_exceeded_response(exceeded: QuotaExceeded) -> Response:
|
|
"""Return the 429 for an exhausted quota, with ``Retry-After`` set to the reset."""
|
|
response = make_response(jsonify(exceeded.to_payload()), 429)
|
|
response.headers["Retry-After"] = str(exceeded.retry_after_seconds)
|
|
# The reset can be weeks away; the OpenAI SDKs would otherwise retry with backoff.
|
|
response.headers["x-should-retry"] = "false"
|
|
return response
|