Update app.py
Browse files
app.py
CHANGED
@@ -94,8 +94,10 @@ async def run_samba_api_inference(query, system_prompt = None, ignore_context=Fa
|
|
94 |
post_response = await asyncio.get_event_loop().run_in_executor(None, lambda: requests.post(config.get("url"), json=payload, headers=headers, stream=True))
|
95 |
post_response.raise_for_status()
|
96 |
except requests.exceptions.HTTPError as e:
|
97 |
-
if post_response.status_code in {401, 503, 504
|
98 |
-
|
|
|
|
|
99 |
st.info("Rate limit hit because of all the pipelined queries, wait one second...")
|
100 |
await asyncio.sleep(num_seconds_to_sleep)
|
101 |
return await run_samba_api_inference(query) # Retry the request
|
|
|
94 |
post_response = await asyncio.get_event_loop().run_in_executor(None, lambda: requests.post(config.get("url"), json=payload, headers=headers, stream=True))
|
95 |
post_response.raise_for_status()
|
96 |
except requests.exceptions.HTTPError as e:
|
97 |
+
if post_response.status_code in {401, 503, 504}:
|
98 |
+
st.info(f"Attempt failed due to rate limit or gate timeout. Status code: {post_response.status_code}. Trying again in {num_seconds_to_sleep} seconds...")
|
99 |
+
return ""
|
100 |
+
if post_response.status_code in {429}:
|
101 |
st.info("Rate limit hit because of all the pipelined queries, wait one second...")
|
102 |
await asyncio.sleep(num_seconds_to_sleep)
|
103 |
return await run_samba_api_inference(query) # Retry the request
|