Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,11 +69,22 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 69 |
print(f"ITEMS {item}")
|
| 70 |
task_id = item.get("task_id")
|
| 71 |
question_text = item.get("question")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
if not task_id or question_text is None:
|
| 73 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 74 |
continue
|
| 75 |
try:
|
| 76 |
-
submitted_answer = agent(question_text)
|
| 77 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 78 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 79 |
except Exception as e:
|
|
|
|
| 69 |
print(f"ITEMS {item}")
|
| 70 |
task_id = item.get("task_id")
|
| 71 |
question_text = item.get("question")
|
| 72 |
+
file_name = item.get("file_name")
|
| 73 |
+
|
| 74 |
+
file_path = ""
|
| 75 |
+
if file_name:
|
| 76 |
+
file_url = f"{DEFAULT_API_URL}/files/{task_id}"
|
| 77 |
+
response = requests.get(file_url)
|
| 78 |
+
respone.raise_for_status()
|
| 79 |
+
os.makedirs("./files, exist_ok= True")
|
| 80 |
+
file_path = f"./files/{file_name}"
|
| 81 |
+
with open(file_path, "wb") as f:
|
| 82 |
+
f.write(response.content)
|
| 83 |
if not task_id or question_text is None:
|
| 84 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 85 |
continue
|
| 86 |
try:
|
| 87 |
+
submitted_answer = agent(question_text, file_path=file_path)
|
| 88 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 89 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 90 |
except Exception as e:
|