marin-iuga commited on
Commit
94d721f
·
verified ·
1 Parent(s): 9fcfed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -4,7 +4,7 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
7
- from huggingface_hub import hf_hub_download
8
 
9
  from smolagents import CodeAgent
10
  from smolagents import OpenAIServerModel
@@ -19,37 +19,41 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
19
  # --- Basic Agent Definition ---
20
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
21
 
 
 
 
 
22
  # GAIA Dataset file dowloading
23
  """
24
  Basic function to download a GAIA dataset validation file
25
  """
26
  def get_GAIA_dataset_validation_file(file_name: str):
27
-
28
  response = hf_hub_download(
29
  repo_id="gaia-benchmark/GAIA",
30
  filename= f"2023/validation/{file_name}",
31
  repo_type="dataset"
32
  )
33
-
34
  return response
35
 
36
  """
37
  Basic function to download a GAIA dataset test file
38
  """
39
  def get_GAIA_dataset_test_file(file_name: str):
40
-
41
  response = hf_hub_download(
42
  repo_id="gaia-benchmark/GAIA",
43
  filename= f"2023/test/{file_name}",
44
  repo_type="dataset"
45
  )
46
-
47
  return response
48
 
49
  """
50
  Basic function to download a GAIA dataset file (validation attempted first)
51
  """
52
  def get_GAIA_dataset_file(file_name: str):
 
 
 
 
53
  response = None
54
  try:
55
  response = get_GAIA_dataset_validation_file(file_name)
@@ -62,10 +66,11 @@ class BasicAgent:
62
  def __init__(self):
63
  print("Starting the initialization of model.")
64
 
65
- model_api_key = os.getenv("OPENAI_API_KEY")
 
66
  model = OpenAIServerModel(
67
  model_id="gpt-4o-mini-2024-07-18",
68
- api_key = model_api_key
69
  )
70
  print("Core model has been initialized.")
71
 
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from huggingface_hub import hf_hub_download, login
8
 
9
  from smolagents import CodeAgent
10
  from smolagents import OpenAIServerModel
 
19
  # --- Basic Agent Definition ---
20
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
21
 
22
+ # Global variables
23
+ HF_DATASET_TOKEN = os.getenv("HF_DATASET_TOKEN")
24
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
25
+
26
  # GAIA Dataset file dowloading
27
  """
28
  Basic function to download a GAIA dataset validation file
29
  """
30
  def get_GAIA_dataset_validation_file(file_name: str):
 
31
  response = hf_hub_download(
32
  repo_id="gaia-benchmark/GAIA",
33
  filename= f"2023/validation/{file_name}",
34
  repo_type="dataset"
35
  )
 
36
  return response
37
 
38
  """
39
  Basic function to download a GAIA dataset test file
40
  """
41
  def get_GAIA_dataset_test_file(file_name: str):
 
42
  response = hf_hub_download(
43
  repo_id="gaia-benchmark/GAIA",
44
  filename= f"2023/test/{file_name}",
45
  repo_type="dataset"
46
  )
 
47
  return response
48
 
49
  """
50
  Basic function to download a GAIA dataset file (validation attempted first)
51
  """
52
  def get_GAIA_dataset_file(file_name: str):
53
+
54
+ global HF_DATASET_TOKEN
55
+ login(token = HF_DATASET_TOKEN)
56
+
57
  response = None
58
  try:
59
  response = get_GAIA_dataset_validation_file(file_name)
 
66
  def __init__(self):
67
  print("Starting the initialization of model.")
68
 
69
+ global OPENAI_API_KEY
70
+
71
  model = OpenAIServerModel(
72
  model_id="gpt-4o-mini-2024-07-18",
73
+ api_key = OPENAI_API_KEY
74
  )
75
  print("Core model has been initialized.")
76