Buckets:

download
raw
3.11 kB
{
"role_mappings": [
{
"role": "Entity",
"status": "present",
"symbol": "chat",
"file": "sdks/python/r_sdk/client.py",
"lines": "200",
"notes": "In-repo Python SDK RClient.chat POSTs to /v1/chat (client.py:233-236) with X-API-Key/Bearer headers, which pass through the traced RateLimitMiddleware; the SDK maps 429 responses to a rate-limit exception (client.py:64)."
},
{
"role": "Enforcer",
"status": "present",
"symbol": "dispatch",
"file": "r_cli/api/rate_limit.py",
"lines": "269",
"notes": "dispatch of RateLimitMiddleware (registered via app.add_middleware(RateLimitMiddleware) in create_app, r_cli/api/server.py:276; app launched as uvicorn factory server.py:1304) derives client id via _get_client_id (rate_limit.py:230: API-key/JWT prefix or IP), computes cost, calls check_rate_limit (rate_limit.py:278) and raises HTTP 429 when blocked, else call_next. Health/docs paths are exempt. An unused alternative per-route dependency exists at rate_limit.py:304 (rate_limit_dependency)."
},
{
"role": "Limiter",
"status": "present",
"symbol": "check_rate_limit",
"file": "r_cli/api/rate_limit.py",
"lines": "153",
"notes": "RateLimiter.check_rate_limit, called from dispatch at rate_limit.py:278, fetches the client's token bucket (get_bucket/get_heavy_bucket, line 165) and decides allow/block via TokenBucket.consume (line 167), returning (allowed, retry_after)."
},
{
"role": "HistoryProvider",
"status": "present",
"symbol": "get_bucket",
"file": "r_cli/api/rate_limit.py",
"lines": "121",
"notes": "RateLimiter.get_bucket (called from check_rate_limit at rate_limit.py:165) returns the per-client TokenBucket kept in the in-memory dict self.buckets (line 117); the bucket's token count/last_refill is the request history, updated by TokenBucket.consume (line 36) on each allowed request. Heavy paths use get_heavy_bucket (line 131) analogously; state is in-process only."
},
{
"role": "PolicyProvider",
"status": "present",
"symbol": "RateLimitConfig",
"file": "r_cli/api/rate_limit.py",
"lines": "58",
"notes": "Policy is a RateLimitConfig (requests_per_minute, burst, heavy limits; bucket_capacity/tokens_per_second at lines 82/77), looked up inline in get_bucket at rate_limit.py:124 from client_configs or the default RATE_LIMIT_TIERS['standard'] (lines 88, 116). No dedicated get-policy method exists, so the config class is cited; set_client_config/set_client_tier (lines 141/148) manage per-client policies."
},
{
"role": "System",
"status": "present",
"symbol": "chat_completions",
"file": "r_cli/api/server.py",
"lines": "628",
"notes": "POST /v1/chat handler chat_completions (a heavy path with cost 2 in _get_cost, rate_limit.py:261) runs only after dispatch calls call_next at rate_limit.py:294; it is the endpoint the SDK Entity targets. All routes registered in register_routes are equally behind the middleware."
}
]
}

Xet Storage Details

Size:
3.11 kB
·
Xet hash:
cc39460295f0476dd1cfb4c094c30989c1a054888486d469f1d882dded9d97c9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.