Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ wiki_search = WikipediaSearchTool(
|
|
| 22 |
content_type="text",
|
| 23 |
extract_format="WIKI",
|
| 24 |
)
|
| 25 |
-
# web_search = DuckDuckGoSearchTool()
|
| 26 |
web_search = GoogleSearchTool(provider="serper")
|
| 27 |
visit_webpage = VisitWebpageTool()
|
| 28 |
final_answer = FinalAnswerTool()
|
|
@@ -96,7 +95,7 @@ class EnhancedAgent:
|
|
| 96 |
self.provider = "auto"
|
| 97 |
self.timeout = 360
|
| 98 |
self.tools = [wiki_search, web_search, visit_webpage, read_file_as_text, reverse_string, final_answer]
|
| 99 |
-
self.auth_imports = ["pandas", "numpy", "datetime", "json", "re", "math", "os", "requests", "csv", "urllib"]
|
| 100 |
self.max_steps = 5
|
| 101 |
self.agent = CodeAgent(
|
| 102 |
model=InferenceClientModel(
|
|
@@ -179,17 +178,28 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 179 |
if not task_id or question_text is None:
|
| 180 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 181 |
continue
|
|
|
|
| 182 |
try:
|
| 183 |
-
answer =
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
else:
|
|
|
|
| 188 |
answers_payload.append({"task_id": task_id, "submitted_answer": answer})
|
| 189 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": answer})
|
| 190 |
except Exception as e:
|
| 191 |
-
|
| 192 |
-
|
| 193 |
|
| 194 |
if not answers_payload:
|
| 195 |
print("Agent did not produce any answers to submit.")
|
|
|
|
| 22 |
content_type="text",
|
| 23 |
extract_format="WIKI",
|
| 24 |
)
|
|
|
|
| 25 |
web_search = GoogleSearchTool(provider="serper")
|
| 26 |
visit_webpage = VisitWebpageTool()
|
| 27 |
final_answer = FinalAnswerTool()
|
|
|
|
| 95 |
self.provider = "auto"
|
| 96 |
self.timeout = 360
|
| 97 |
self.tools = [wiki_search, web_search, visit_webpage, read_file_as_text, reverse_string, final_answer]
|
| 98 |
+
self.auth_imports = ["pandas", "numpy", "datetime", "json", "re", "math", "os", "io", "requests", "csv", "urllib"]
|
| 99 |
self.max_steps = 5
|
| 100 |
self.agent = CodeAgent(
|
| 101 |
model=InferenceClientModel(
|
|
|
|
| 178 |
if not task_id or question_text is None:
|
| 179 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 180 |
continue
|
| 181 |
+
|
| 182 |
try:
|
| 183 |
+
answer = None
|
| 184 |
+
tries = 0
|
| 185 |
+
while (answer is None) and (tries < 5):
|
| 186 |
+
maybe_answer = agent(question_text, file_name)
|
| 187 |
+
if maybe_answer.startswith("Error in generating final LLM output: 504 Server Error: Gateway Time-out for"):
|
| 188 |
+
answer = None
|
| 189 |
+
tries += 1
|
| 190 |
+
time.sleep(10)
|
| 191 |
+
else:
|
| 192 |
+
answer = maybe_answer
|
| 193 |
+
if answer is None:
|
| 194 |
+
print(f"Error running agent on task {task_id}: {maybe_answer}")
|
| 195 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {maybe_answer}"})
|
| 196 |
else:
|
| 197 |
+
print(f"Successfully ran agent on task {task_id}.")
|
| 198 |
answers_payload.append({"task_id": task_id, "submitted_answer": answer})
|
| 199 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": answer})
|
| 200 |
except Exception as e:
|
| 201 |
+
print(f"Error running agent on task {task_id}: {e}")
|
| 202 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
| 203 |
|
| 204 |
if not answers_payload:
|
| 205 |
print("Agent did not produce any answers to submit.")
|