jjvelezo commited on
Commit
c328ad6
·
verified ·
1 Parent(s): ab9ed38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from agent import DuckDuckGoAgent
7
 
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -20,10 +20,9 @@ class BasicAgent:
20
 
21
  def run_and_submit_all(profile: gr.OAuthProfile | None):
22
  """
23
- Fetches all questions, runs the DuckDuckGoAgent on them, submits all answers,
24
  and displays the results.
25
  """
26
- # --- Determine HF Space Runtime URL and Repo URL ---
27
  space_id = os.getenv("SPACE_ID")
28
 
29
  if profile:
@@ -39,7 +38,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
39
 
40
  # 1. Instantiate Agent
41
  try:
42
- agent = DuckDuckGoAgent()
43
  except Exception as e:
44
  print(f"Error instantiating agent: {e}")
45
  return f"Error initializing agent: {e}", None
@@ -83,12 +82,12 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
83
  print("Agent did not produce any answers to submit.")
84
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
85
 
86
- # 4. Preparar la sumisión
87
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
88
  status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
89
  print(status_update)
90
 
91
- # 5. Imprimir los resultados en lugar de enviar
92
  print(f"Agent finished. Results (not submitting):")
93
  for result in results_log:
94
  print(f"Task ID: {result['Task ID']}")
@@ -101,7 +100,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
101
 
102
  # --- Build Gradio Interface using Blocks ---
103
  with gr.Blocks() as demo:
104
- gr.Markdown("# Basic Agent Evaluation Runner")
105
  gr.Markdown(
106
  """
107
  **Instructions:**
@@ -147,5 +146,5 @@ if __name__ == "__main__":
147
 
148
  print("-"*(60 + len(" App Starting ")) + "\n")
149
 
150
- print("Launching Gradio Interface for Basic Agent Evaluation...")
151
  demo.launch(debug=True, share=False)
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from agent import HuggingFaceAgent # Cambiar el agente a HuggingFace
7
 
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
20
 
21
  def run_and_submit_all(profile: gr.OAuthProfile | None):
22
  """
23
+ Fetches all questions, runs the HuggingFaceAgent on them, submits all answers,
24
  and displays the results.
25
  """
 
26
  space_id = os.getenv("SPACE_ID")
27
 
28
  if profile:
 
38
 
39
  # 1. Instantiate Agent
40
  try:
41
+ agent = HuggingFaceAgent()
42
  except Exception as e:
43
  print(f"Error instantiating agent: {e}")
44
  return f"Error initializing agent: {e}", None
 
82
  print("Agent did not produce any answers to submit.")
83
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
84
 
85
+ # 4. Prepare Submission
86
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
87
  status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
88
  print(status_update)
89
 
90
+ # 5. Print Results (not submit)
91
  print(f"Agent finished. Results (not submitting):")
92
  for result in results_log:
93
  print(f"Task ID: {result['Task ID']}")
 
100
 
101
  # --- Build Gradio Interface using Blocks ---
102
  with gr.Blocks() as demo:
103
+ gr.Markdown("# HuggingFace Agent Evaluation Runner")
104
  gr.Markdown(
105
  """
106
  **Instructions:**
 
146
 
147
  print("-"*(60 + len(" App Starting ")) + "\n")
148
 
149
+ print("Launching Gradio Interface for HuggingFace Agent Evaluation...")
150
  demo.launch(debug=True, share=False)