lezaf commited on
Commit
08283c8
·
1 Parent(s): 6b69490

Fix SuperAgent data parameter validation

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -30,7 +30,7 @@ class SuperAgent:
30
  print("SuperAgent initialized.")
31
  self.agent = build_agent(provider="google") # Change to "hf" for HuggingFace
32
 
33
- def __call__(self, data: str) -> str:
34
  """
35
  Args:
36
  data (str): A string containing the question to be answered.
@@ -41,7 +41,8 @@ class SuperAgent:
41
  }
42
  """
43
  # Quick validation of input data (TODO: Use pydantic for schema)
44
- if not data.get("question") or not data.get("task_id") or not data.get("file_name"):
 
45
  raise ValueError("Input data must contain 'question', 'task_id', and 'file_name'.")
46
 
47
  task_id, question, file_name = data["task_id"], data["question"], data["file_name"]
@@ -154,6 +155,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
154
  subset_task_ids = [line.strip() for line in f if line.strip()]
155
 
156
  if task_id not in subset_task_ids:
 
157
  continue
158
 
159
  try:
@@ -222,7 +224,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
222
 
223
  # --- Build Gradio Interface using Blocks ---
224
  with gr.Blocks() as demo:
225
- gr.Markdown("# Basic Agent Evaluation Runner")
226
  gr.Markdown(
227
  """
228
  **Instructions:**
 
30
  print("SuperAgent initialized.")
31
  self.agent = build_agent(provider="google") # Change to "hf" for HuggingFace
32
 
33
+ def __call__(self, data: dict) -> str:
34
  """
35
  Args:
36
  data (str): A string containing the question to be answered.
 
41
  }
42
  """
43
  # Quick validation of input data (TODO: Use pydantic for schema)
44
+ required_keys = ["question", "task_id", "file_name"]
45
+ if not all(k in data for k in required_keys):
46
  raise ValueError("Input data must contain 'question', 'task_id', and 'file_name'.")
47
 
48
  task_id, question, file_name = data["task_id"], data["question"], data["file_name"]
 
155
  subset_task_ids = [line.strip() for line in f if line.strip()]
156
 
157
  if task_id not in subset_task_ids:
158
+ print(f"Skipping task {task_id} as it is not in the subset of tasks to run.")
159
  continue
160
 
161
  try:
 
224
 
225
  # --- Build Gradio Interface using Blocks ---
226
  with gr.Blocks() as demo:
227
+ gr.Markdown("# Super Agent Evaluation Runner")
228
  gr.Markdown(
229
  """
230
  **Instructions:**