GoodLuckChuck commited on
Commit
d063073
·
verified ·
1 Parent(s): 8ab4960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -143,7 +143,7 @@ class GoogleSearchTool(Tool):
143
  "type": "string",
144
  "description": "The search provider. MUST be 'serpapi'.",
145
  "default": "serpapi",
146
- "nullable": True # <<< FIX: Added nullable: True
147
  }
148
  }
149
  output_type = "string"
@@ -156,10 +156,6 @@ class GoogleSearchTool(Tool):
156
 
157
  async def forward(self, query: str, provider: str = "serpapi") -> str:
158
  print(f"DEBUG: GoogleSearchTool.forward called with query: '{query}', provider: '{provider}'")
159
- # The 'provider' parameter in the 'inputs' dictionary now has "default": "serpapi" and "nullable": True.
160
- # smol-agents should use the default if the LLM doesn't specify 'provider'.
161
- # If the LLM *does* specify 'provider', it should be "serpapi" as per the system prompt.
162
- # This explicit check remains as a safeguard.
163
  if provider != "serpapi":
164
  logger.warning(f"GoogleSearchTool called with an unexpected provider: '{provider}'. The system prompt and tool definition instruct the LLM to use 'serpapi'.")
165
  return "Error: Invalid search provider. Only 'serpapi' is supported for the web_search tool as per current agent configuration."
@@ -479,19 +475,23 @@ def process_all_questions(agent: ChuckAgent, questions_data: List[Dict[str, Any]
479
  print(f"DEBUG: Processing task {i+1}/{len(questions_data)}, ID: {task_id}")
480
  try:
481
  model_ans, reasoning = agent(question_text)
482
- payload_item = {"task_id": task_id, "model_answer": model_ans}
 
483
  if reasoning:
484
  payload_item["reasoning_trace"] = reasoning
485
  answers_payload.append(payload_item)
 
486
  results_log_data.append({
487
  "Task ID": task_id, "Question": question_text,
488
- "Submitted Answer": model_ans, "Reasoning Trace": reasoning
 
489
  })
490
  except Exception as e:
491
  print(f"DEBUG: ERROR - Error running agent on task {task_id}: {e}")
492
  logger.error(f"Error running agent on task {task_id} ('{question_text[:50]}...'): {e}", exc_info=True)
493
  error_answer = f"AGENT_CALL_ERROR: {str(e)}"
494
- answers_payload.append({"task_id": task_id, "model_answer": error_answer, "reasoning_trace": str(e)})
 
495
  results_log_data.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": error_answer, "Reasoning Trace": str(e)})
496
  print(f"DEBUG: process_all_questions finished. Produced {len(answers_payload)} answers.")
497
  return answers_payload, results_log_data
@@ -503,6 +503,11 @@ def submit_answers(base_api_url: str, username: str, agent_code_url: str, answer
503
  return "Agent did not produce any answers to submit."
504
  submit_url = f"{base_api_url}{CONFIG.SUBMIT_URL_PATH}"
505
  submission_data = {"username": username.strip(), "agent_code": agent_code_url, "answers": answers_payload}
 
 
 
 
 
506
  logger.info(f"Submitting {len(answers_payload)} answers for user '{username}' to {submit_url}...")
507
  try:
508
  response = requests.post(submit_url, json=submission_data, timeout=60)
 
143
  "type": "string",
144
  "description": "The search provider. MUST be 'serpapi'.",
145
  "default": "serpapi",
146
+ "nullable": True
147
  }
148
  }
149
  output_type = "string"
 
156
 
157
  async def forward(self, query: str, provider: str = "serpapi") -> str:
158
  print(f"DEBUG: GoogleSearchTool.forward called with query: '{query}', provider: '{provider}'")
 
 
 
 
159
  if provider != "serpapi":
160
  logger.warning(f"GoogleSearchTool called with an unexpected provider: '{provider}'. The system prompt and tool definition instruct the LLM to use 'serpapi'.")
161
  return "Error: Invalid search provider. Only 'serpapi' is supported for the web_search tool as per current agent configuration."
 
475
  print(f"DEBUG: Processing task {i+1}/{len(questions_data)}, ID: {task_id}")
476
  try:
477
  model_ans, reasoning = agent(question_text)
478
+ # FIX: Use 'submitted_answer' as the key for the server
479
+ payload_item = {"task_id": task_id, "submitted_answer": model_ans}
480
  if reasoning:
481
  payload_item["reasoning_trace"] = reasoning
482
  answers_payload.append(payload_item)
483
+
484
  results_log_data.append({
485
  "Task ID": task_id, "Question": question_text,
486
+ "Submitted Answer": model_ans, # This key is for local logging, can remain model_ans or change
487
+ "Reasoning Trace": reasoning
488
  })
489
  except Exception as e:
490
  print(f"DEBUG: ERROR - Error running agent on task {task_id}: {e}")
491
  logger.error(f"Error running agent on task {task_id} ('{question_text[:50]}...'): {e}", exc_info=True)
492
  error_answer = f"AGENT_CALL_ERROR: {str(e)}"
493
+ # FIX: Use 'submitted_answer' as the key for the server
494
+ answers_payload.append({"task_id": task_id, "submitted_answer": error_answer, "reasoning_trace": str(e)})
495
  results_log_data.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": error_answer, "Reasoning Trace": str(e)})
496
  print(f"DEBUG: process_all_questions finished. Produced {len(answers_payload)} answers.")
497
  return answers_payload, results_log_data
 
503
  return "Agent did not produce any answers to submit."
504
  submit_url = f"{base_api_url}{CONFIG.SUBMIT_URL_PATH}"
505
  submission_data = {"username": username.strip(), "agent_code": agent_code_url, "answers": answers_payload}
506
+
507
+ # Debug: Print a snippet of the submission data to verify the key change
508
+ if answers_payload:
509
+ print(f"DEBUG: Sample of first answer payload being sent: {answers_payload[0]}")
510
+
511
  logger.info(f"Submitting {len(answers_payload)} answers for user '{username}' to {submit_url}...")
512
  try:
513
  response = requests.post(submit_url, json=submission_data, timeout=60)