Increased timeout to 300
Browse files
app.py
CHANGED
|
@@ -97,6 +97,15 @@ class BasicAgent:
|
|
| 97 |
formatted_question = f"{self.system_prompt}\n\nQuestion: {question}\n\n"
|
| 98 |
answer = self.agent.run(formatted_question)
|
| 99 |
answer = str(answer).strip() if answer is not None else "No answer produced."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# answer = self.agent.run(question)
|
| 101 |
print(f"Agent returning answer: {answer[:100]}...")
|
| 102 |
fixed_answer = answer
|
|
@@ -201,13 +210,13 @@ https://agents-course-unit4-scoring.hf.space/files/{task_id}
|
|
| 201 |
task_id = item.get("task_id")
|
| 202 |
question_text = item.get("question")
|
| 203 |
try:
|
| 204 |
-
result_task_id, result_question, submitted_answer = future.result(timeout=
|
| 205 |
if result_task_id is None:
|
| 206 |
continue
|
| 207 |
answers_payload.append({"task_id": result_task_id, "submitted_answer": submitted_answer})
|
| 208 |
results_log.append({"Task ID": result_task_id, "Question": result_question, "Submitted Answer": submitted_answer})
|
| 209 |
except TimeoutError:
|
| 210 |
-
print(f"Task {task_id} timed out
|
| 211 |
answers_payload.append({"task_id": task_id, "submitted_answer": "TIMEOUT"})
|
| 212 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": "TIMEOUT"})
|
| 213 |
except Exception as e:
|
|
|
|
| 97 |
formatted_question = f"{self.system_prompt}\n\nQuestion: {question}\n\n"
|
| 98 |
answer = self.agent.run(formatted_question)
|
| 99 |
answer = str(answer).strip() if answer is not None else "No answer produced."
|
| 100 |
+
|
| 101 |
+
# Detect raw scratchpad instead of clean answer
|
| 102 |
+
if "Thought:" in answer or "```" in answer or "Calling tools:" in answer:
|
| 103 |
+
print("Warning: agent returned scratchpad, extracting final answer...")
|
| 104 |
+
if "YOUR FINAL ANSWER" in answer:
|
| 105 |
+
answer = answer.split("YOUR FINAL ANSWER")[-1].strip().lstrip(":").strip()
|
| 106 |
+
else:
|
| 107 |
+
answer = "Agent did not produce a final answer."
|
| 108 |
+
|
| 109 |
# answer = self.agent.run(question)
|
| 110 |
print(f"Agent returning answer: {answer[:100]}...")
|
| 111 |
fixed_answer = answer
|
|
|
|
| 210 |
task_id = item.get("task_id")
|
| 211 |
question_text = item.get("question")
|
| 212 |
try:
|
| 213 |
+
result_task_id, result_question, submitted_answer = future.result(timeout=300)
|
| 214 |
if result_task_id is None:
|
| 215 |
continue
|
| 216 |
answers_payload.append({"task_id": result_task_id, "submitted_answer": submitted_answer})
|
| 217 |
results_log.append({"Task ID": result_task_id, "Question": result_question, "Submitted Answer": submitted_answer})
|
| 218 |
except TimeoutError:
|
| 219 |
+
print(f"Task {task_id} timed out, skipping.")
|
| 220 |
answers_payload.append({"task_id": task_id, "submitted_answer": "TIMEOUT"})
|
| 221 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": "TIMEOUT"})
|
| 222 |
except Exception as e:
|