Add print traceback
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
""" Basic Agent Evaluation Runner"""
|
| 2 |
import os
|
|
|
|
| 3 |
import inspect
|
| 4 |
import gradio as gr
|
| 5 |
import requests
|
|
@@ -55,6 +56,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 55 |
try:
|
| 56 |
agent = BasicAgent()
|
| 57 |
except Exception as e:
|
|
|
|
| 58 |
print(f"Error instantiating agent: {e}")
|
| 59 |
return f"Error initializing agent: {e}", None
|
| 60 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
|
@@ -72,14 +74,18 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 72 |
return "Fetched questions list is empty or invalid format.", None
|
| 73 |
print(f"Fetched {len(questions_data)} questions.")
|
| 74 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 75 |
print(f"Error fetching questions: {e}")
|
| 76 |
return f"Error fetching questions: {e}", None
|
| 77 |
except requests.exceptions.JSONDecodeError as e:
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
except Exception as e:
|
|
|
|
| 82 |
print(f"An unexpected error occurred fetching questions: {e}")
|
|
|
|
| 83 |
return f"An unexpected error occurred fetching questions: {e}", None
|
| 84 |
|
| 85 |
# 3. Run your Agent
|
|
@@ -97,8 +103,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 97 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 98 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 99 |
except Exception as e:
|
| 100 |
-
|
| 101 |
-
|
|
|
|
| 102 |
|
| 103 |
if not answers_payload:
|
| 104 |
print("Agent did not produce any answers to submit.")
|
|
|
|
| 1 |
""" Basic Agent Evaluation Runner"""
|
| 2 |
import os
|
| 3 |
+
from traceback import print_exc
|
| 4 |
import inspect
|
| 5 |
import gradio as gr
|
| 6 |
import requests
|
|
|
|
| 56 |
try:
|
| 57 |
agent = BasicAgent()
|
| 58 |
except Exception as e:
|
| 59 |
+
print_exc()
|
| 60 |
print(f"Error instantiating agent: {e}")
|
| 61 |
return f"Error initializing agent: {e}", None
|
| 62 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
|
|
|
| 74 |
return "Fetched questions list is empty or invalid format.", None
|
| 75 |
print(f"Fetched {len(questions_data)} questions.")
|
| 76 |
except requests.exceptions.RequestException as e:
|
| 77 |
+
print_exc()
|
| 78 |
print(f"Error fetching questions: {e}")
|
| 79 |
return f"Error fetching questions: {e}", None
|
| 80 |
except requests.exceptions.JSONDecodeError as e:
|
| 81 |
+
print_exc()
|
| 82 |
+
print(f"Error decoding JSON response from questions endpoint: {e}")
|
| 83 |
+
print(f"Response text: {response.text[:500]}")
|
| 84 |
+
return f"Error decoding server response for questions: {e}", None
|
| 85 |
except Exception as e:
|
| 86 |
+
print_exc()
|
| 87 |
print(f"An unexpected error occurred fetching questions: {e}")
|
| 88 |
+
|
| 89 |
return f"An unexpected error occurred fetching questions: {e}", None
|
| 90 |
|
| 91 |
# 3. Run your Agent
|
|
|
|
| 103 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 104 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 105 |
except Exception as e:
|
| 106 |
+
print_exc()
|
| 107 |
+
print(f"Error running agent on task {task_id}: {e}")
|
| 108 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
| 109 |
|
| 110 |
if not answers_payload:
|
| 111 |
print("Agent did not produce any answers to submit.")
|