Rahmat82 commited on
Commit
f1de923
·
verified ·
1 Parent(s): 76df00f

input validation

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -9,8 +9,8 @@ SECRET_KEY = os.environ.get("summarizer")
9
 
10
  # asynchronous function
11
  async def summarize(text, retries=3):
12
- if len(text) < 35:
13
- return "Error: Input should be at least few sentences long!"
14
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
15
  data = {
16
  "inputs": text,
@@ -39,7 +39,7 @@ async def summarize(text, retries=3):
39
  await asyncio.sleep(1)
40
  continue
41
  else:
42
- return f"Error: {e.status}, message='{e.message}'"
43
 
44
  # define gradio interface
45
  iface = gr.Interface(
 
9
 
10
  # asynchronous function
11
  async def summarize(text, retries=3):
12
+ if len(text) < 75:
13
+ return "<span style='color: red;'>Error: Input should contain more than a few sentences.</span>"
14
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
15
  data = {
16
  "inputs": text,
 
39
  await asyncio.sleep(1)
40
  continue
41
  else:
42
+ return f"<span style='color: red;'>Error: {e.status}, message='{e.message}'</span>"
43
 
44
  # define gradio interface
45
  iface = gr.Interface(