GoReed commited on
Commit
8c5ec67
Β·
verified Β·
1 Parent(s): 020caac

Added App file

Browse files
Files changed (1) hide show
  1. app.py +39 -0
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()