alisamak commited on
Commit
37d071a
·
verified ·
1 Parent(s): 999ae93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -7,6 +7,9 @@ import pandas as pd
7
  from evaluate_agent import evaluate_agent, test_questions
8
  from LG_agent import BasicAgent
9
  # from LG_agent import test_questions, evaluate_agent
 
 
 
10
 
11
  # (Keep Constants as is)
12
  # --- Constants ---
@@ -23,6 +26,29 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
23
  # print(f"Agent returning fixed answer: {fixed_answer}")
24
  # return fixed_answer
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  def run_and_submit_all( profile: gr.OAuthProfile | None):
27
  """
28
  Fetches all questions, runs the BasicAgent on them, submits all answers,
@@ -166,6 +192,8 @@ with gr.Blocks() as demo:
166
 
167
  test_eval_button = gr.Button("🔍 Evaluate on Local GAIA Test Set")
168
 
 
 
169
  run_button = gr.Button("Run Evaluation & Submit All Answers")
170
 
171
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
@@ -182,6 +210,11 @@ with gr.Blocks() as demo:
182
  outputs=[status_output, results_table]
183
  )
184
 
 
 
 
 
 
185
 
186
  if __name__ == "__main__":
187
  print("\n" + "-"*30 + " App Starting " + "-"*30)
 
7
  from evaluate_agent import evaluate_agent, test_questions
8
  from LG_agent import BasicAgent
9
  # from LG_agent import test_questions, evaluate_agent
10
+ import json
11
+ import csv
12
+ from datasets import load_dataset
13
 
14
  # (Keep Constants as is)
15
  # --- Constants ---
 
26
  # print(f"Agent returning fixed answer: {fixed_answer}")
27
  # return fixed_answer
28
 
29
+ def download_gaia_to_csv():
30
+ try:
31
+ # Load dataset
32
+ dataset = load_dataset("gaia-benchmark/GAIA", split="dev", trust_remote_code=True)
33
+
34
+ # Define output file
35
+ output_path = "gaia_dev_data.csv"
36
+
37
+ # Extract all keys from the first entry for CSV headers
38
+ keys = dataset[0].keys()
39
+
40
+ # Write to CSV
41
+ with open(output_path, "w", newline="", encoding="utf-8") as f:
42
+ writer = csv.DictWriter(f, fieldnames=keys)
43
+ writer.writeheader()
44
+ for row in dataset:
45
+ writer.writerow(row)
46
+
47
+ return f"✅ GAIA dev dataset saved as CSV at {output_path}"
48
+ except Exception as e:
49
+ return f"❌ Error: {e}"
50
+
51
+
52
  def run_and_submit_all( profile: gr.OAuthProfile | None):
53
  """
54
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
192
 
193
  test_eval_button = gr.Button("🔍 Evaluate on Local GAIA Test Set")
194
 
195
+ download_db_button = gr.Button("=== Download DB ====")
196
+
197
  run_button = gr.Button("Run Evaluation & Submit All Answers")
198
 
199
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
 
210
  outputs=[status_output, results_table]
211
  )
212
 
213
+ download_db_button.click(
214
+ fn=download_gaia_to_csv,
215
+ outputs=[status_output]
216
+ )
217
+
218
 
219
  if __name__ == "__main__":
220
  print("\n" + "-"*30 + " App Starting " + "-"*30)