sabonzo commited on
Commit
9e890c7
·
verified ·
1 Parent(s): d373c57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -430,7 +430,7 @@ class SabonzoAgent:
430
  return_intermediate_steps=False,
431
  )
432
 
433
- def __call__(self, question: str, task_id: str) -> str:
434
  """Processes a single question, handling file downloads and analysis."""
435
  logging.info(f"--- Starting Task {task_id} ---")
436
  logging.info(f"Question: {question[:150]}...")
@@ -474,21 +474,13 @@ class SabonzoAgent:
474
 
475
  # --- Step 2: Download GAIA File if needed ---
476
  if needs_gaia_file:
477
- file_url = f"{self.api_url}/files/{task_id}"
478
- logging.info(f"Task {task_id} requires GAIA {file_type} file download from: {file_url}")
479
- file_path = download_file(file_url, self.temp_dir, task_id)
480
- if not file_path:
481
- # If download failed, set analysis_result to error and update context
482
- analysis_result = f"ERROR: Failed to download the required {file_type} file for task {task_id} from {file_url}."
483
- analysis_context = f"Analysis Context: {analysis_result}"
484
- # Set final_answer to the error if file is absolutely required
485
- final_answer = analysis_result
486
- elif not file_path.exists() or file_path.stat().st_size == 0:
487
- # Handle cases where download function might return path but file is empty/gone
488
- analysis_result = f"ERROR: Downloaded {file_type} file for task {task_id} is missing or empty at {file_path}."
489
  analysis_context = f"Analysis Context: {analysis_result}"
490
  final_answer = analysis_result
491
- file_path = None # Ensure file_path is None if file is invalid
 
 
492
 
493
  # --- Step 3: Perform Analysis if download was successful ---
494
  # Only proceed if file_path is valid and we haven't already set final_answer due to download error
@@ -772,6 +764,7 @@ def run_evaluation(profile: gr.OAuthProfile | None):
772
  for i, item in enumerate(questions_data):
773
  task_id = item.get("task_id")
774
  question_text = item.get("question")
 
775
  progress_text = f"Running question {i+1}/{num_questions} (Task ID: {task_id})..."
776
  logging.info(progress_text)
777
 
@@ -789,7 +782,7 @@ def run_evaluation(profile: gr.OAuthProfile | None):
789
  start_time_task = time.time()
790
  submitted_answer = f"ERROR: Agent failed to return an answer for task {task_id}" # Default
791
  try:
792
- submitted_answer = agent(question_text, str(task_id))
793
  elapsed_time_task = time.time() - start_time_task
794
  logging.info(f"Task {task_id} completed in {elapsed_time_task:.2f} seconds.")
795
 
 
430
  return_intermediate_steps=False,
431
  )
432
 
433
+ def __call__(self, question: str, task_id: str, file_url: str = None) -> str:
434
  """Processes a single question, handling file downloads and analysis."""
435
  logging.info(f"--- Starting Task {task_id} ---")
436
  logging.info(f"Question: {question[:150]}...")
 
474
 
475
  # --- Step 2: Download GAIA File if needed ---
476
  if needs_gaia_file:
477
+ if not file_url:
478
+ analysis_result = f"ERROR: No file_url provided for task {task_id}"
 
 
 
 
 
 
 
 
 
 
479
  analysis_context = f"Analysis Context: {analysis_result}"
480
  final_answer = analysis_result
481
+ else:
482
+ logging.info(f"Task {task_id} requires GAIA {file_type} file download from: {file_url}")
483
+ file_path = download_file(file_url, self.temp_dir, task_id)
484
 
485
  # --- Step 3: Perform Analysis if download was successful ---
486
  # Only proceed if file_path is valid and we haven't already set final_answer due to download error
 
764
  for i, item in enumerate(questions_data):
765
  task_id = item.get("task_id")
766
  question_text = item.get("question")
767
+ gaia_file_url = item.get("file_url")
768
  progress_text = f"Running question {i+1}/{num_questions} (Task ID: {task_id})..."
769
  logging.info(progress_text)
770
 
 
782
  start_time_task = time.time()
783
  submitted_answer = f"ERROR: Agent failed to return an answer for task {task_id}" # Default
784
  try:
785
+ submitted_answer = agent(question_text, str(task_id), gaia_file_url)
786
  elapsed_time_task = time.time() - start_time_task
787
  logging.info(f"Task {task_id} completed in {elapsed_time_task:.2f} seconds.")
788