ilyassman commited on
Commit
ff4855a
·
verified ·
1 Parent(s): 7270083

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -1
app.py CHANGED
@@ -168,4 +168,33 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
168
  for item in questions:
169
  task_id = item["task_id"]
170
  q = item["question"]
171
- file_path = download_file(task_id, item.get("file_name",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  for item in questions:
169
  task_id = item["task_id"]
170
  q = item["question"]
171
+ file_path = download_file(task_id, item.get("file_name", ""))
172
+ ans = ask_agent(agent, q, file_path)
173
+ print(f"[réponse] {task_id}: {ans}")
174
+ answers.append({"task_id": task_id, "submitted_answer": ans})
175
+ log.append({"Task ID": task_id, "Question": q[:100], "Réponse": ans})
176
+ time.sleep(2)
177
+
178
+ payload = {"username": username, "agent_code": agent_code, "answers": answers}
179
+ try:
180
+ res = requests.post(f"{API_URL}/submit", json=payload, timeout=120).json()
181
+ msg = (
182
+ f"Utilisateur: {res.get('username')}\n"
183
+ f"Score: {res.get('score')}% "
184
+ f"({res.get('correct_count')}/{res.get('total_attempted')})\n"
185
+ f"{res.get('message', '')}"
186
+ )
187
+ except Exception as e:
188
+ msg = f"Erreur lors de la soumission: {e}"
189
+ return msg, pd.DataFrame(log)
190
+
191
+ with gr.Blocks() as demo:
192
+ gr.Markdown("# Agent GAIA - Unit 4")
193
+ gr.LoginButton()
194
+ btn = gr.Button("Run Evaluation & Submit All Answers")
195
+ status = gr.Textbox(label="Résultat", lines=5)
196
+ table = gr.DataFrame(label="Réponses")
197
+ btn.click(run_and_submit_all, outputs=[status, table])
198
+
199
+ if __name__ == "__main__":
200
+ demo.launch()