Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,8 +109,9 @@ async def process_question(agent, question_text: str, task_id: str, file_path: O
|
|
| 109 |
submitted_answer = None
|
| 110 |
max_retries = 5
|
| 111 |
retry_delay = 30 # Initial retry delay in seconds
|
|
|
|
| 112 |
|
| 113 |
-
for attempt in range(max_retries):
|
| 114 |
try:
|
| 115 |
while not token_bucket.consume(1):
|
| 116 |
print(f"Rate limit reached for task {task_id}. Waiting to retry...")
|
|
@@ -118,13 +119,13 @@ async def process_question(agent, question_text: str, task_id: str, file_path: O
|
|
| 118 |
print(f"Processing task {task_id} (attempt {attempt + 1})...")
|
| 119 |
submitted_answer = await asyncio.wait_for(
|
| 120 |
agent(question_text, file_path),
|
| 121 |
-
timeout=
|
| 122 |
)
|
| 123 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 124 |
print(f"Completed task {task_id} with answer: {submitted_answer[:50]}...")
|
| 125 |
|
| 126 |
#Addl sleep
|
| 127 |
-
await asyncio.sleep(
|
| 128 |
return {"task_id": task_id, "submitted_answer": submitted_answer}
|
| 129 |
except aiohttp.ClientResponseError as e:
|
| 130 |
if e.status == 429:
|
|
@@ -138,15 +139,15 @@ async def process_question(agent, question_text: str, task_id: str, file_path: O
|
|
| 138 |
print(f"Failed task {task_id}: {submitted_answer}")
|
| 139 |
return None
|
| 140 |
except asyncio.TimeoutError:
|
| 141 |
-
submitted_answer = f"AGENT ERROR: Timeout after
|
| 142 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 143 |
print(f"Failed task {task_id}: {submitted_answer}")
|
| 144 |
return None
|
| 145 |
except Exception as e:
|
| 146 |
submitted_answer = f"AGENT ERROR: {e}"
|
| 147 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 148 |
-
|
| 149 |
-
|
| 150 |
|
| 151 |
async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
| 152 |
"""
|
|
|
|
| 109 |
submitted_answer = None
|
| 110 |
max_retries = 5
|
| 111 |
retry_delay = 30 # Initial retry delay in seconds
|
| 112 |
+
atimeout = 200
|
| 113 |
|
| 114 |
+
for attempt in range(max_retries +1):
|
| 115 |
try:
|
| 116 |
while not token_bucket.consume(1):
|
| 117 |
print(f"Rate limit reached for task {task_id}. Waiting to retry...")
|
|
|
|
| 119 |
print(f"Processing task {task_id} (attempt {attempt + 1})...")
|
| 120 |
submitted_answer = await asyncio.wait_for(
|
| 121 |
agent(question_text, file_path),
|
| 122 |
+
timeout=atimeout # Increased timeout for audio processing
|
| 123 |
)
|
| 124 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 125 |
print(f"Completed task {task_id} with answer: {submitted_answer[:50]}...")
|
| 126 |
|
| 127 |
#Addl sleep
|
| 128 |
+
await asyncio.sleep(retry_delay)
|
| 129 |
return {"task_id": task_id, "submitted_answer": submitted_answer}
|
| 130 |
except aiohttp.ClientResponseError as e:
|
| 131 |
if e.status == 429:
|
|
|
|
| 139 |
print(f"Failed task {task_id}: {submitted_answer}")
|
| 140 |
return None
|
| 141 |
except asyncio.TimeoutError:
|
| 142 |
+
submitted_answer = f"AGENT ERROR: Timeout after {atimeout} seconds"
|
| 143 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 144 |
print(f"Failed task {task_id}: {submitted_answer}")
|
| 145 |
return None
|
| 146 |
except Exception as e:
|
| 147 |
submitted_answer = f"AGENT ERROR: {e}"
|
| 148 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 149 |
+
print(f"Failed task {task_id}: {submitted_answer}")
|
| 150 |
+
return None
|
| 151 |
|
| 152 |
async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
| 153 |
"""
|