Spaces:
Runtime error
Runtime error
Added App file
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
|
| 3 |
+
from agent import fetch_questions, run_agent_on_question, submit_answers
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
print("π₯ Fetching questions...")
|
| 9 |
+
questions = fetch_questions()
|
| 10 |
+
if not questions:
|
| 11 |
+
print("No questions fetched. Exiting.")
|
| 12 |
+
return
|
| 13 |
+
|
| 14 |
+
answers = []
|
| 15 |
+
for q in questions:
|
| 16 |
+
print(f"π Running agent on: {q['question']}")
|
| 17 |
+
try:
|
| 18 |
+
result = run_agent_on_question(q)
|
| 19 |
+
print(f"β
Answer: {result}\n")
|
| 20 |
+
answers.append({
|
| 21 |
+
"task_id": q["task_id"],
|
| 22 |
+
"submitted_answer": result
|
| 23 |
+
})
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"β Error on question {q['task_id']}: {e}")
|
| 26 |
+
answers.append({
|
| 27 |
+
"task_id": q["task_id"],
|
| 28 |
+
"submitted_answer": "error"
|
| 29 |
+
})
|
| 30 |
+
|
| 31 |
+
os.makedirs("data", exist_ok=True)
|
| 32 |
+
with open("data/answers_output.json", "w") as f:
|
| 33 |
+
json.dump(answers, f, indent=2)
|
| 34 |
+
|
| 35 |
+
print("π€ Submitting answers...")
|
| 36 |
+
submit_answers(answers)
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
main()
|