Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -243,7 +243,7 @@ def compress_data(c, instruct, history):
|
|
243 |
|
244 |
|
245 |
|
246 |
-
def summarize(inp,history,data=None,
|
247 |
if inp == "":
|
248 |
inp = "Process this data"
|
249 |
history.clear()
|
@@ -260,20 +260,21 @@ def summarize(inp,history,data=None,file=None,url=None,pdf_url=None):
|
|
260 |
rawp = str(out)
|
261 |
else:
|
262 |
data=out
|
263 |
-
if
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
|
|
277 |
if data != "Error" and data != "":
|
278 |
print(inp)
|
279 |
out = str(data)
|
@@ -317,7 +318,7 @@ with gr.Blocks() as app:
|
|
317 |
with gr.Tab("Text"):
|
318 |
data=gr.Textbox(label="Input Data (paste text)", lines=6)
|
319 |
with gr.Tab("File"):
|
320 |
-
file=gr.
|
321 |
with gr.Tab("URL"):
|
322 |
url = gr.Textbox(label="URL")
|
323 |
with gr.Tab("PDF URL"):
|
|
|
243 |
|
244 |
|
245 |
|
246 |
+
def summarize(inp,history,data=None,files=None,url=None,pdf_url=None):
|
247 |
if inp == "":
|
248 |
inp = "Process this data"
|
249 |
history.clear()
|
|
|
260 |
rawp = str(out)
|
261 |
else:
|
262 |
data=out
|
263 |
+
if files:
|
264 |
+
for i, file in enumerate(files):
|
265 |
+
try:
|
266 |
+
print (file)
|
267 |
+
if file.endswith(".pdf"):
|
268 |
+
zz=read_pdf(file)
|
269 |
+
print (zz)
|
270 |
+
data=f'{data}\nFile Name ({file}):\n{zz}'
|
271 |
+
elif file.endswith(".txt"):
|
272 |
+
zz=read_txt(file)
|
273 |
+
print (zz)
|
274 |
+
data=f'{data}\nFile Name ({file}):\n{zz}'
|
275 |
+
except Exception as e:
|
276 |
+
data=f'{data}\nError opening File Name ({file})'
|
277 |
+
print (e)
|
278 |
if data != "Error" and data != "":
|
279 |
print(inp)
|
280 |
out = str(data)
|
|
|
318 |
with gr.Tab("Text"):
|
319 |
data=gr.Textbox(label="Input Data (paste text)", lines=6)
|
320 |
with gr.Tab("File"):
|
321 |
+
file=gr.Files(label="Input File (.pdf .txt)")
|
322 |
with gr.Tab("URL"):
|
323 |
url = gr.Textbox(label="URL")
|
324 |
with gr.Tab("PDF URL"):
|