Rahmat82 commited on
Commit
d213004
·
verified ·
1 Parent(s): 9347162

connection attempt update

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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=5):
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}"}
@@ -34,9 +34,9 @@ async def summarize(text, retries=5):
34
  except aiohttp.ClientResponseError as e:
35
  # retry only if the error is 503 (Service Unavailable)
36
  if e.status == 503 and attempt < retries - 1:
37
- print(f"Retry attempt {attempt+1} for 503 error.")
38
  # add a short delay before retrying
39
- await asyncio.sleep(2)
40
  continue
41
  else:
42
  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=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}"}
 
34
  except aiohttp.ClientResponseError as e:
35
  # retry only if the error is 503 (Service Unavailable)
36
  if e.status == 503 and attempt < retries - 1:
37
+ # print(f"Retry attempt {attempt+1} for 503 error.")
38
  # add a short delay before retrying
39
+ await asyncio.sleep(1)
40
  continue
41
  else:
42
  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!"