Thanh Vinh Vo commited on
Commit
2fc20ae
·
1 Parent(s): 3541ef3
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -59,14 +59,14 @@ class BasicAgent:
59
  return result
60
 
61
 
62
- def run_and_submit_all(questions_limit: str, profile: gr.OAuthProfile | None):
63
  """
64
  Fetches all questions, runs the BasicAgent on them, submits all answers,
65
  and displays the results.
66
  """
67
  # --- Determine HF Space Runtime URL and Repo URL ---
68
  space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
69
- LIMIT = int(questions_limit)
70
 
71
  if profile:
72
  username = f"{profile.username}"
@@ -95,7 +95,7 @@ def run_and_submit_all(questions_limit: str, profile: gr.OAuthProfile | None):
95
  try:
96
  response = requests.get(questions_url, timeout=15)
97
  response.raise_for_status()
98
- questions_data = response.json()[:LIMIT]
99
  if not questions_data:
100
  print("Fetched questions list is empty.")
101
  return "Fetched questions list is empty or invalid format.", None
@@ -221,7 +221,7 @@ with gr.Blocks() as demo:
221
  gr.LoginButton()
222
 
223
  questions_limit = gr.Textbox(
224
- label="How many questions to solve", lines=1, interactive=True, value="1"
225
  )
226
  run_button = gr.Button("Run Evaluation & Submit All Answers")
227
  status_output = gr.Textbox(
 
59
  return result
60
 
61
 
62
+ def run_and_submit_all(questions_index: str, profile: gr.OAuthProfile | None):
63
  """
64
  Fetches all questions, runs the BasicAgent on them, submits all answers,
65
  and displays the results.
66
  """
67
  # --- Determine HF Space Runtime URL and Repo URL ---
68
  space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
69
+ QUESTION_INDEX = int(questions_index)
70
 
71
  if profile:
72
  username = f"{profile.username}"
 
95
  try:
96
  response = requests.get(questions_url, timeout=15)
97
  response.raise_for_status()
98
+ questions_data = [response.json()[QUESTION_INDEX]] if QUESTION_INDEX > 0 else response.json()
99
  if not questions_data:
100
  print("Fetched questions list is empty.")
101
  return "Fetched questions list is empty or invalid format.", None
 
221
  gr.LoginButton()
222
 
223
  questions_limit = gr.Textbox(
224
+ label="Question index to solve (-1 to solve all)", lines=1, interactive=True, value="0"
225
  )
226
  run_button = gr.Button("Run Evaluation & Submit All Answers")
227
  status_output = gr.Textbox(