SergeyO7 commited on
Commit
8873299
·
verified ·
1 Parent(s): a902a0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -23,7 +23,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
23
 
24
  # Rate limiting configuration
25
  MAX_CONCURRENT_REQUESTS = 1 # Adjust based on performance needs
26
- REQUEST_DELAY = 8.0 # 2 seconds delay to meet 30 RPM
27
 
28
  async def fetch_questions(session: aiohttp.ClientSession, questions_url: str) -> list:
29
  """Fetch questions asynchronously."""
@@ -48,7 +48,8 @@ async def submit_answers(session: aiohttp.ClientSession, submit_url: str, submis
48
  try:
49
  async with session.post(submit_url, json=submission_data, timeout=60) as response:
50
  response.raise_for_status()
51
- return await response.json()
 
52
  except aiohttp.ClientResponseError as e:
53
  print(f"Submission Failed: Server responded with status {e.status}. Detail: {e.message}")
54
  return None
@@ -71,7 +72,10 @@ async def process_question(agent, question_text: str, task_id: str, semaphore: a
71
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
72
  return None
73
  finally:
74
- await asyncio.sleep(REQUEST_DELAY) # Enforce delay after each request
 
 
 
75
 
76
  async def run_and_submit_all(profile: gr.OAuthProfile | None):
77
  """
 
23
 
24
  # Rate limiting configuration
25
  MAX_CONCURRENT_REQUESTS = 1 # Adjust based on performance needs
26
+ REQUEST_DELAY = 9.0 # 2 seconds delay to meet 30 RPM
27
 
28
  async def fetch_questions(session: aiohttp.ClientSession, questions_url: str) -> list:
29
  """Fetch questions asynchronously."""
 
48
  try:
49
  async with session.post(submit_url, json=submission_data, timeout=60) as response:
50
  response.raise_for_status()
51
+ return await response.json
52
+ ()
53
  except aiohttp.ClientResponseError as e:
54
  print(f"Submission Failed: Server responded with status {e.status}. Detail: {e.message}")
55
  return None
 
72
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
73
  return None
74
  finally:
75
+ if "Malko" in question or "Mercedes Sosa" in question or "Teal" in question or "chess" in question or "Marisa" in question or "Yankee" in question:
76
+ await asyncio.sleep(12) # Enforce delay after each request
77
+ else:
78
+ await asyncio.sleep(REQUEST_DELAY) # Enforce delay after each request
79
 
80
  async def run_and_submit_all(profile: gr.OAuthProfile | None):
81
  """