hassenhamdi commited on
Commit
068bf30
·
verified ·
1 Parent(s): 1939b22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -22
app.py CHANGED
@@ -3,37 +3,24 @@ import pandas as pd
3
  import gradio as gr
4
  import logging
5
  import time
6
- from dotenv import load_dotenv # Import load_dotenv
7
 
 
 
8
  from settings import Settings
9
  from evaluator import Evaluator
10
  from runner import Runner
11
 
12
- # Load environment variables from .env file at the very beginning
13
- load_dotenv()
14
-
15
- # Explicitly set environment variables for Pydantic Settings to ensure they are picked up
16
- # This is a safeguard in case pydantic-settings doesn't automatically find them
17
- # in certain execution environments (e.g., Hugging Face Spaces)
18
- if os.getenv("USERNAME"):
19
- os.environ["USERNAME"] = os.getenv("USERNAME")
20
- if os.getenv("SPACE_ID"):
21
- os.environ["SPACE_ID"] = os.getenv("SPACE_ID")
22
- if os.getenv("GEMINI_API_KEY"):
23
- os.environ["GEMINI_API_KEY"] = os.getenv("GEMINI_API_KEY")
24
-
25
-
26
  # Configure logging
27
  logging.basicConfig(level=logging.INFO, force=True)
28
  logger = logging.getLogger(__name__)
29
 
30
  # Initialize settings, evaluator, and runner
31
- # Rely on pydantic-settings to load username and space_id from environment variables or .env file
32
- settings = Settings()
33
  evaluator = Evaluator(settings)
34
  runner = Runner(settings)
35
 
36
 
 
37
  LOGIN_MESSAGE = "Please Login to Hugging Face with the button."
38
  EMPTY_RESULTS_TABLE = pd.DataFrame(columns=['task_id', 'question', 'answer'])
39
 
@@ -100,17 +87,15 @@ with gr.Blocks() as demo:
100
  gr.Markdown(
101
  """
102
  **Instructions:**
103
-
104
  1. Log in to your Hugging Face account using the button below.
105
  2. Click 'Get One Answer' to run the agent on a random question or 'Get All Answers' to run all.
106
  3. Click 'Submit Answers' to submit answers for evaluation. **Your HF username will be submitted for leaderboard tracking.**
107
-
108
  ---
109
  **Disclaimers:**
110
  * Running 'Get All Answers' can take significant time as the agent processes all 20 questions.
111
  * Agent logs are detailed (DEBUG level) and may appear interleaved due to parallel execution.
112
  * The 'Submit Answers' button uses the most recent agent answers cached locally for your username.
113
- * **API Keys Required:** Ensure `GEMINI_API_KEY`, `USERNAME`, and `SPACE_ID` are set as Space Secrets (or environment variables if running locally).
114
  """
115
  )
116
 
@@ -158,5 +143,4 @@ if __name__ == "__main__":
158
  logger.info("-"*(60 + len(" App Starting ")) + "\n")
159
 
160
  logger.info("Launching Gradio Interface for GAIA Agent Evaluation...")
161
- demo.launch(debug=True, share=False)
162
-
 
3
  import gradio as gr
4
  import logging
5
  import time
 
6
 
7
+
8
+ # Import the new Settings, Evaluator, and Runner classes
9
  from settings import Settings
10
  from evaluator import Evaluator
11
  from runner import Runner
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # Configure logging
14
  logging.basicConfig(level=logging.INFO, force=True)
15
  logger = logging.getLogger(__name__)
16
 
17
  # Initialize settings, evaluator, and runner
18
+ settings = Settings()
 
19
  evaluator = Evaluator(settings)
20
  runner = Runner(settings)
21
 
22
 
23
+
24
  LOGIN_MESSAGE = "Please Login to Hugging Face with the button."
25
  EMPTY_RESULTS_TABLE = pd.DataFrame(columns=['task_id', 'question', 'answer'])
26
 
 
87
  gr.Markdown(
88
  """
89
  **Instructions:**
 
90
  1. Log in to your Hugging Face account using the button below.
91
  2. Click 'Get One Answer' to run the agent on a random question or 'Get All Answers' to run all.
92
  3. Click 'Submit Answers' to submit answers for evaluation. **Your HF username will be submitted for leaderboard tracking.**
 
93
  ---
94
  **Disclaimers:**
95
  * Running 'Get All Answers' can take significant time as the agent processes all 20 questions.
96
  * Agent logs are detailed (DEBUG level) and may appear interleaved due to parallel execution.
97
  * The 'Submit Answers' button uses the most recent agent answers cached locally for your username.
98
+ * **API Keys Required:** Ensure `GEMINI_API_KEY` is set as a Space Secret (or environment variable if running locally).
99
  """
100
  )
101
 
 
143
  logger.info("-"*(60 + len(" App Starting ")) + "\n")
144
 
145
  logger.info("Launching Gradio Interface for GAIA Agent Evaluation...")
146
+ demo.launch(debug=True, share=False)