Spaces:
Sleeping
Sleeping
File size: 1,100 Bytes
06e83d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from agent import LangGraphAgent
from questions import questions
import json
agent = LangGraphAgent()
answers_payload = []
for item in questions:
task_id = item.get("task_id")
question_text = item.get("question")
file_name = item.get("file_name")
if not task_id or question_text is None:
print(f"Skipping item with missing task_id or question: {item}")
continue
try:
if file_name:
question_text += f"\n\nFile url: {api_url}/files/{task_id}"
try:
ext = file_name.split('.')[-1]
question_text += f"\n File extension is (.{ext} file)"
except:
pass
submitted_answer = agent(question_text)
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
print({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
except Exception as e:
print(f"Error running agent on task {task_id}: {e}")
print(answers_payload)
with open('answers.json', 'w') as f:
json.dump(answers_payload, f)
|