Commit ·
24f3a85
1
Parent(s): becb416
Fix missing answers_payload.append in loop
Browse files
app.py
CHANGED
|
@@ -63,7 +63,7 @@ CRITICAL RULES:
|
|
| 63 |
6. Always search the web for factual questions.
|
| 64 |
7. Never include FINAL ANSWER in your response.
|
| 65 |
8. Match the exact format requested in the question.
|
| 66 |
-
|
| 67 |
"""
|
| 68 |
|
| 69 |
def build_agent():
|
|
@@ -100,8 +100,10 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 100 |
questions_data = response.json()
|
| 101 |
except Exception as e:
|
| 102 |
return f"Error fetching questions: {e}", None
|
|
|
|
| 103 |
results_log = []
|
| 104 |
answers_payload = []
|
|
|
|
| 105 |
for item in questions_data:
|
| 106 |
task_id = item.get("task_id")
|
| 107 |
question_text = item.get("question")
|
|
@@ -116,8 +118,15 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 116 |
submitted_answer = submitted_answer[len(prefix):].strip().strip(":")
|
| 117 |
except Exception as e:
|
| 118 |
submitted_answer = f"AGENT ERROR: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
if not answers_payload:
|
| 120 |
return "Agent produced no answers.", pd.DataFrame(results_log)
|
|
|
|
| 121 |
try:
|
| 122 |
response = requests.post(f"{DEFAULT_API_URL}/submit",
|
| 123 |
json={"username": username.strip(), "agent_code": agent_code, "answers": answers_payload},
|
|
@@ -155,4 +164,4 @@ if __name__ == "__main__":
|
|
| 155 |
print(f"Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
|
| 156 |
print("-"*74 + "\n")
|
| 157 |
print("Launching Gradio Interface...")
|
| 158 |
-
demo.launch(debug=True, share=False)
|
|
|
|
| 63 |
6. Always search the web for factual questions.
|
| 64 |
7. Never include FINAL ANSWER in your response.
|
| 65 |
8. Match the exact format requested in the question.
|
| 66 |
+
9. If you cannot find the answer, return your best single-word or single-number guess. Never return a long explanation.
|
| 67 |
"""
|
| 68 |
|
| 69 |
def build_agent():
|
|
|
|
| 100 |
questions_data = response.json()
|
| 101 |
except Exception as e:
|
| 102 |
return f"Error fetching questions: {e}", None
|
| 103 |
+
|
| 104 |
results_log = []
|
| 105 |
answers_payload = []
|
| 106 |
+
|
| 107 |
for item in questions_data:
|
| 108 |
task_id = item.get("task_id")
|
| 109 |
question_text = item.get("question")
|
|
|
|
| 118 |
submitted_answer = submitted_answer[len(prefix):].strip().strip(":")
|
| 119 |
except Exception as e:
|
| 120 |
submitted_answer = f"AGENT ERROR: {e}"
|
| 121 |
+
print(f"Error on task {task_id}: {e}")
|
| 122 |
+
|
| 123 |
+
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 124 |
+
results_log.append({"Task ID": task_id, "Question": question_text[:120], "Submitted Answer": submitted_answer})
|
| 125 |
+
print(f"Task {task_id}: {submitted_answer[:80]}")
|
| 126 |
+
|
| 127 |
if not answers_payload:
|
| 128 |
return "Agent produced no answers.", pd.DataFrame(results_log)
|
| 129 |
+
|
| 130 |
try:
|
| 131 |
response = requests.post(f"{DEFAULT_API_URL}/submit",
|
| 132 |
json={"username": username.strip(), "agent_code": agent_code, "answers": answers_payload},
|
|
|
|
| 164 |
print(f"Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
|
| 165 |
print("-"*74 + "\n")
|
| 166 |
print("Launching Gradio Interface...")
|
| 167 |
+
demo.launch(debug=True, share=False)
|