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

input validation

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  import aiohttp
3
  import asyncio
4
  import os
5
- import re
6
 
7
  # API endpoint - model name
8
  API_URL = "https://api-inference.huggingface.co/models/Rahmat82/t5-small-finetuned-summarization-xsum"
@@ -10,7 +9,7 @@ SECRET_KEY = os.environ.get("summarizer")
10
 
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 = {
 
2
  import aiohttp
3
  import asyncio
4
  import os
 
5
 
6
  # API endpoint - model name
7
  API_URL = "https://api-inference.huggingface.co/models/Rahmat82/t5-small-finetuned-summarization-xsum"
 
9
 
10
  # asynchronous function
11
  async def summarize(text, retries=3):
12
+ if len(text)<250:
13
  return "⛔ You input is too short! It should contain more than a few sentences for summarization."
14
  headers = {"Authorization": f"Bearer {SECRET_KEY}"}
15
  data = {