alisamak commited on
Commit
5f6319f
·
verified ·
1 Parent(s): 37d071a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -28,16 +28,20 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
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()
@@ -48,7 +52,6 @@ def download_gaia_to_csv():
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,
 
28
 
29
  def download_gaia_to_csv():
30
  try:
31
+ # Authenticate
32
+ token = os.getenv("HF_TOKEN")
33
+ if not token:
34
+ return "❌ HF_TOKEN not found. Please set it in your Space's secrets."
35
+
36
+ login(token) # log in using the token
37
+
38
  # Load dataset
39
  dataset = load_dataset("gaia-benchmark/GAIA", split="dev", trust_remote_code=True)
40
 
41
+ # Save to CSV
42
  output_path = "gaia_dev_data.csv"
 
 
43
  keys = dataset[0].keys()
44
 
 
45
  with open(output_path, "w", newline="", encoding="utf-8") as f:
46
  writer = csv.DictWriter(f, fieldnames=keys)
47
  writer.writeheader()
 
52
  except Exception as e:
53
  return f"❌ Error: {e}"
54
 
 
55
  def run_and_submit_all( profile: gr.OAuthProfile | None):
56
  """
57
  Fetches all questions, runs the BasicAgent on them, submits all answers,