Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ class BasicAgent:
|
|
| 31 |
try:
|
| 32 |
messages = self.graph.invoke({"messages": messages})
|
| 33 |
except Exception as e:
|
| 34 |
-
print(f"
|
| 35 |
raise # 保留原始异常以便上层处理
|
| 36 |
answer = messages['messages'][-1].content
|
| 37 |
return answer[14:]
|
|
@@ -58,8 +58,13 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 58 |
|
| 59 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 60 |
try:
|
|
|
|
|
|
|
| 61 |
agent = BasicAgent()
|
| 62 |
-
except Exception as e
|
|
|
|
|
|
|
|
|
|
| 63 |
print(f"Error instantiating agent: {e}")
|
| 64 |
return f"Error initializing agent: {e}", None
|
| 65 |
# 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)
|
|
@@ -88,18 +93,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 88 |
return f"An unexpected error occurred fetching questions: {e}", None
|
| 89 |
|
| 90 |
# 3. Run your Agent
|
| 91 |
-
# 初始化Supabase客户端后添加
|
| 92 |
-
try:
|
| 93 |
-
# 测试查询documents表是否存在(返回1表示存在)
|
| 94 |
-
test_query = "SELECT 1 FROM documents LIMIT 1;"
|
| 95 |
-
result = supabase.sql(test_query).execute()
|
| 96 |
-
if result.data:
|
| 97 |
-
print("Supabase连接成功,documents表存在")
|
| 98 |
-
else:
|
| 99 |
-
print("Supabase连接成功,但documents表无数据")
|
| 100 |
-
except Exception as e:
|
| 101 |
-
print(f"Supabase连接失败!错误详情:{str(e)}")
|
| 102 |
-
|
| 103 |
results_log = []
|
| 104 |
answers_payload = []
|
| 105 |
print(f"Running agent on {len(questions_data)} questions...")
|
|
|
|
| 31 |
try:
|
| 32 |
messages = self.graph.invoke({"messages": messages})
|
| 33 |
except Exception as e:
|
| 34 |
+
print(f"@@@@@@@@: {question[:50]}... - {e}")
|
| 35 |
raise # 保留原始异常以便上层处理
|
| 36 |
answer = messages['messages'][-1].content
|
| 37 |
return answer[14:]
|
|
|
|
| 58 |
|
| 59 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 60 |
try:
|
| 61 |
+
import traceback
|
| 62 |
+
from datetime import datetime
|
| 63 |
agent = BasicAgent()
|
| 64 |
+
except Exception as e
|
| 65 |
+
error_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 66 |
+
error_type = type(e).__name__
|
| 67 |
+
error_traceback = traceback.format_exc()
|
| 68 |
print(f"Error instantiating agent: {e}")
|
| 69 |
return f"Error initializing agent: {e}", None
|
| 70 |
# 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)
|
|
|
|
| 93 |
return f"An unexpected error occurred fetching questions: {e}", None
|
| 94 |
|
| 95 |
# 3. Run your Agent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
results_log = []
|
| 97 |
answers_payload = []
|
| 98 |
print(f"Running agent on {len(questions_data)} questions...")
|