Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
import time
|
|
|
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
@@ -81,11 +82,16 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 81 |
continue
|
| 82 |
try:
|
| 83 |
# We add to counter the token rate limit usage by openai of 30000 TPM
|
| 84 |
-
time.sleep(
|
| 85 |
# end insertion
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
except Exception as e:
|
| 90 |
print(f"Error running agent on task {task_id}: {e}")
|
| 91 |
# we limit the error message lentgh so we can still submit the other answers
|
|
@@ -101,6 +107,10 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 101 |
status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
|
| 102 |
print(status_update)
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
# 5. Submit
|
| 105 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
| 106 |
try:
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
import time
|
| 7 |
+
import joblib
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 82 |
continue
|
| 83 |
try:
|
| 84 |
# We add to counter the token rate limit usage by openai of 30000 TPM
|
| 85 |
+
time.sleep(10)
|
| 86 |
# end insertion
|
| 87 |
+
try:
|
| 88 |
+
submitted_answer = agent(question_text)
|
| 89 |
+
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 90 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 91 |
+
except Exception as e:
|
| 92 |
+
answers_payload.append({"task_id": task_id, "submitted_answer": str(submitted_answer)})
|
| 93 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": str(submitted_answer)})
|
| 94 |
+
|
| 95 |
except Exception as e:
|
| 96 |
print(f"Error running agent on task {task_id}: {e}")
|
| 97 |
# we limit the error message lentgh so we can still submit the other answers
|
|
|
|
| 107 |
status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
|
| 108 |
print(status_update)
|
| 109 |
|
| 110 |
+
|
| 111 |
+
# HERE WE SAVE THE PAYLOAD TO DEBU SUBMISSION
|
| 112 |
+
joblib.dump(answers_payload,"answer_payload.joblib")
|
| 113 |
+
|
| 114 |
# 5. Submit
|
| 115 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
| 116 |
try:
|