Spaces:
Sleeping
Sleeping
File size: 1,035 Bytes
d416acc 032a55d 0a8ea31 a10514d 0a8ea31 a10514d 0a8ea31 032a55d a10514d 0a8ea31 a10514d 0a8ea31 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """Grader for rate_limit task: 429 Too Many Requests."""
def grade() -> float:
"""Grade the rate_limit task. Returns float strictly between 0 and 1."""
try:
import sys
from pathlib import Path
_root = str(Path(__file__).resolve().parent.parent.parent)
if _root not in sys.path:
sys.path.insert(0, _root)
from environment.api_triage_env import APITriageEnv
from environment.incident_generator import get_incident_by_type
env = APITriageEnv(max_steps=10)
env.incident = get_incident_by_type("rate_limit")
if env.incident is None:
return 0.1
env.fix_applied = False
env.done = False
env.step_counter = 0
env.total_reward = 0.0
for action in ["inspect_logs", "wait_retry", "resolve"]:
_, _, done, info = env.step(action)
if done:
return 0.95 if info.get("resolution") == "success" else 0.1
return 0.1
except Exception:
return 0.1
|