zolicsaki commited on
Commit
c18ceb6
·
verified ·
1 Parent(s): a318445

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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, 429}:
98
- print(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
  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