Rahmat82 commited on
Commit
339d882
·
verified ·
1 Parent(s): d1b874a

input validation

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -11,7 +11,7 @@ SECRET_KEY = os.environ.get("summarizer")
11
  # asynchronous function
12
  async def summarize(text, retries=3):
13
  if len(re.findall(r'[.!?]+', text)) < 3 and len(text)<60:
14
- return "<span style='color: red;'>Error: Input should contain more than a few sentences.</span>"
15
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
16
  data = {
17
  "inputs": text,
@@ -40,7 +40,7 @@ async def summarize(text, retries=3):
40
  await asyncio.sleep(1)
41
  continue
42
  else:
43
- return f"<span style='color: red;'>Error: {e.status}, message='{e.message}'</span>"
44
 
45
  # define gradio interface
46
  iface = gr.Interface(
 
11
  # asynchronous function
12
  async def summarize(text, retries=3):
13
  if len(re.findall(r'[.!?]+', text)) < 3 and len(text)<60:
14
+ return " You input is too short! It should contain more than a few sentences for summarization."
15
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
16
  data = {
17
  "inputs": text,
 
40
  await asyncio.sleep(1)
41
  continue
42
  else:
43
+ return f"Error: {e.status}, message='{e.message}'. Please try again 🔁"
44
 
45
  # define gradio interface
46
  iface = gr.Interface(