Datawithsarah commited on
Commit
d7be3df
·
1 Parent(s): a992787

Update agent logic and add test interface

Browse files
Files changed (1) hide show
  1. app.py +31 -51
app.py CHANGED
@@ -189,56 +189,36 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
189
 
190
  # --- Build Gradio Interface using Blocks ---
191
  with gr.Blocks() as demo:
192
- gr.Markdown("# Basic Agent Evaluation Runner")
193
- gr.Markdown(
194
- """
195
- **Instructions:**
196
-
197
- 1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
198
- 2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
199
- 3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
200
-
201
- ---
202
- **Disclaimers:**
203
- Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
204
- This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
205
- """
206
- )
207
-
208
- gr.LoginButton()
209
-
210
- run_button = gr.Button("Run Evaluation & Submit All Answers")
211
-
212
- status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
213
- # Removed max_rows=10 from DataFrame constructor
214
- results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
215
-
216
- run_button.click(
217
- fn=run_and_submit_all,
218
- outputs=[status_output, results_table]
219
- )
 
 
220
 
221
  if __name__ == "__main__":
222
- print("\n" + "-"*30 + " App Starting " + "-"*30)
223
- # Check for SPACE_HOST and SPACE_ID at startup for information
224
- space_host_startup = os.getenv("SPACE_HOST")
225
- space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
226
-
227
- if space_host_startup:
228
- print(f"✅ SPACE_HOST found: {space_host_startup}")
229
- print(f" Runtime URL should be: https://{space_host_startup}.hf.space")
230
- else:
231
- print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
232
-
233
- if space_id_startup: # Print repo URLs if SPACE_ID is found
234
- print(f"✅ SPACE_ID found: {space_id_startup}")
235
- print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
236
- print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
237
- else:
238
- print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
239
-
240
- print("-"*(60 + len(" App Starting ")) + "\n")
241
-
242
- print("Launching Gradio Interface for Basic Agent Evaluation...")
243
- demo.launch(debug=True, share=False)
244
- test_interface.launch(debug=True, share=False)
 
189
 
190
  # --- Build Gradio Interface using Blocks ---
191
  with gr.Blocks() as demo:
192
+ gr.Markdown("# 🤖 GAIA Final Assignment: Agent Runner")
193
+
194
+ with gr.Tab("🔍 Test Your Agent"):
195
+ gr.Markdown("Use this to test how your agent responds to custom questions before running full evaluation.")
196
+ test_input = gr.Textbox(label="Enter a Question", placeholder="e.g., How many studio albums...")
197
+ test_output = gr.Textbox(label="Agent's Answer", interactive=False)
198
+ test_button = gr.Button("Test Agent")
199
+ test_button.click(fn=test_agent_response, inputs=test_input, outputs=test_output)
200
+
201
+ with gr.Tab("📤 Run Evaluation & Submit"):
202
+ gr.Markdown(
203
+ """
204
+ **Instructions:**
205
+
206
+ 1. Modify your agent logic.
207
+ 2. Log in to Hugging Face below.
208
+ 3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, and see your score.
209
+
210
+ ---
211
+ """
212
+ )
213
+ gr.LoginButton()
214
+ run_button = gr.Button("Run Evaluation & Submit All Answers")
215
+ status_output = gr.Textbox(label="Submission Result", lines=5, interactive=False)
216
+ results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
217
+
218
+ run_button.click(
219
+ fn=run_and_submit_all,
220
+ outputs=[status_output, results_table]
221
+ )
222
 
223
  if __name__ == "__main__":
224
+ demo.launch(debug=True)