Toumaima commited on
Commit
b3a6900
·
verified ·
1 Parent(s): 7a6b525

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -59,6 +59,11 @@ class BasicAgent:
59
  }
60
  ) / len(words)
61
  return reversed_ratio > 0.3
 
 
 
 
 
62
 
63
  def solve_riddle(self, question: str) -> str:
64
  question = question[::-1]
@@ -121,7 +126,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
121
  continue
122
  try:
123
  submitted_answer = agent(question_text)
124
- answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
125
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
126
  except Exception as e:
127
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
 
59
  }
60
  ) / len(words)
61
  return reversed_ratio > 0.3
62
+
63
+ def format_final_answer(self, answer: str) -> str:
64
+ """Ensure final answer matches required format, and force it to be on one line."""
65
+ cleaned = " ".join(answer.split()) # Remove extra spaces and make sure it's a single line
66
+ return f"FINAL ANSWER: {cleaned}"
67
 
68
  def solve_riddle(self, question: str) -> str:
69
  question = question[::-1]
 
126
  continue
127
  try:
128
  submitted_answer = agent(question_text)
129
+ answers_payload.append({"task_id": task_id, "submitted_answer": format_final_answer(submitted_answer)})
130
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
131
  except Exception as e:
132
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})