benjosaur commited on
Commit
795f653
·
1 Parent(s): e6af243

Add async logic

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -70,7 +70,7 @@ class BasicAgent:
70
  return final_answer
71
 
72
 
73
- def run_and_submit_all(profile: gr.OAuthProfile | None):
74
  """
75
  Fetches all questions, runs the BasicAgent on them, submits all answers,
76
  and displays the results.
@@ -124,7 +124,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
124
  results_log = []
125
  answers_payload = []
126
  print(f"Running agent on {len(questions_data)} questions...")
127
- for item in questions_data:
128
  task_id = item.get("task_id")
129
  question_text = item.get("question")
130
  file_name = item.get("file_name")
@@ -132,7 +132,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
132
  print(f"Skipping item with missing task_id or question: {item}")
133
  continue
134
  try:
135
- submitted_answer = agent(question_text, task_id, file_name)
136
  answers_payload.append(
137
  {"task_id": task_id, "submitted_answer": submitted_answer}
138
  )
 
70
  return final_answer
71
 
72
 
73
+ async def run_and_submit_all(profile: gr.OAuthProfile | None):
74
  """
75
  Fetches all questions, runs the BasicAgent on them, submits all answers,
76
  and displays the results.
 
124
  results_log = []
125
  answers_payload = []
126
  print(f"Running agent on {len(questions_data)} questions...")
127
+ async for item in questions_data:
128
  task_id = item.get("task_id")
129
  question_text = item.get("question")
130
  file_name = item.get("file_name")
 
132
  print(f"Skipping item with missing task_id or question: {item}")
133
  continue
134
  try:
135
+ submitted_answer = await agent(question_text, task_id, file_name)
136
  answers_payload.append(
137
  {"task_id": task_id, "submitted_answer": submitted_answer}
138
  )
requirements.txt CHANGED
@@ -9,4 +9,5 @@ Pillow
9
  yt-dlp
10
  html2text
11
  llama-index-utils-workflow
12
- llama-index-llms-huggingface-api
 
 
9
  yt-dlp
10
  html2text
11
  llama-index-utils-workflow
12
+ llama-index-llms-huggingface-api
13
+ asyncio