real-jiakai commited on
Commit
e850f95
·
verified ·
1 Parent(s): 5693254

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -5,6 +5,7 @@ import inspect
5
  import pandas as pd
6
  from agent import ClaudeAgent
7
  from dotenv import load_dotenv
 
8
 
9
  # Load environment variables
10
  load_dotenv()
@@ -85,7 +86,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
85
  results_log = []
86
  answers_payload = []
87
  print(f"Running agent on {len(questions_data)} questions...")
88
- for item in questions_data:
89
  task_id = item.get("task_id")
90
  question_text = item.get("question")
91
  if not task_id or question_text is None:
@@ -95,6 +96,11 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
95
  submitted_answer = agent(question_text)
96
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
97
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
 
 
 
 
 
98
  except Exception as e:
99
  print(f"Error running agent on task {task_id}: {e}")
100
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
 
5
  import pandas as pd
6
  from agent import ClaudeAgent
7
  from dotenv import load_dotenv
8
+ import time
9
 
10
  # Load environment variables
11
  load_dotenv()
 
86
  results_log = []
87
  answers_payload = []
88
  print(f"Running agent on {len(questions_data)} questions...")
89
+ for i, item in enumerate(questions_data):
90
  task_id = item.get("task_id")
91
  question_text = item.get("question")
92
  if not task_id or question_text is None:
 
96
  submitted_answer = agent(question_text)
97
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
98
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
99
+
100
+ if (i + 1) % 5 == 0 and i < len(questions_data) - 1:
101
+ print(f"Have completed {i + 1} questions. Sleep 60s to prevent the rate limit...")
102
+ time.sleep(60)
103
+
104
  except Exception as e:
105
  print(f"Error running agent on task {task_id}: {e}")
106
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})