Rahmat82 commited on
Commit
c0bf46f
·
verified ·
1 Parent(s): 1fa3f20

call establishment attemp

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -8,7 +8,7 @@ API_URL = "https://api-inference.huggingface.co/models/Rahmat82/t5-small-finetun
8
  SECRET_KEY = os.environ.get("summarizer")
9
 
10
  # asynchronous function
11
- async def summarize(text, retries=3):
12
  if len(text) < 250:
13
  return "⛔ You input is too short! Please input a longer text for summarization."
14
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
@@ -35,7 +35,7 @@ async def summarize(text, retries=3):
35
  # retry only if the error is 503 (Service Unavailable)
36
  if isinstance(e, aiohttp.ClientResponseError) and e.status == 503 and attempt < retries - 1:
37
  # add a short delay before retrying
38
- await asyncio.sleep(2)
39
  continue
40
  else:
41
  return "Oops! 🙈 It looks like those mischievous monkeys🐒 might be swinging around the server, causing a bit of chaos with the cables. Please try it again!"
 
8
  SECRET_KEY = os.environ.get("summarizer")
9
 
10
  # asynchronous function
11
+ async def summarize(text, retries=4):
12
  if len(text) < 250:
13
  return "⛔ You input is too short! Please input a longer text for summarization."
14
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
 
35
  # retry only if the error is 503 (Service Unavailable)
36
  if isinstance(e, aiohttp.ClientResponseError) and e.status == 503 and attempt < retries - 1:
37
  # add a short delay before retrying
38
+ await asyncio.sleep(2.5)
39
  continue
40
  else:
41
  return "Oops! 🙈 It looks like those mischievous monkeys🐒 might be swinging around the server, causing a bit of chaos with the cables. Please try it again!"