input validation
Browse files
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) <
|
13 |
-
return "Error: Input should
|
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(
|