input validation
Browse files
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 "
|
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"
|
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(
|