Spaces:
Runtime error
Runtime error
| # app.py | |
| from agent import fetch_questions, run_agent_on_question, submit_answers | |
| import json | |
| import os | |
| def get_answers(): | |
| print("π₯ Fetching questions...") | |
| questions = fetch_questions() | |
| if not questions: | |
| print("No questions fetched. Exiting.") | |
| return | |
| answers = [] | |
| for q in questions: | |
| print(f"π Running agent on: {q['question']}") | |
| try: | |
| result = run_agent_on_question(q) | |
| print(f"β Answer: {result}\n") | |
| answers.append({ | |
| "task_id": q["task_id"], | |
| "submitted_answer": result | |
| }) | |
| except Exception as e: | |
| print(f"β Error on question {q['task_id']}: {e}") | |
| answers.append({ | |
| "task_id": q["task_id"], | |
| "submitted_answer": "error" | |
| }) | |
| os.makedirs("data", exist_ok=True) | |
| with open("data/answers_output.json", "w") as f: | |
| json.dump(answers, f, indent=2) | |
| print("π€ Submitting answers...") | |
| submit_answers(answers) | |
| return | |
| if __name__ == "__main__": | |
| get_answers() | |