Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,7 +154,7 @@ def compress_data(c, instruct, history):
|
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
-
def summarize(inp,history,data=None,
|
| 158 |
if inp == "":
|
| 159 |
inp = "Summarize this data"
|
| 160 |
|
|
@@ -163,15 +163,16 @@ def summarize(inp,history,data=None,file=None):
|
|
| 163 |
yield "",history
|
| 164 |
if file:
|
| 165 |
try:
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
except Exception as e:
|
| 176 |
data = "Error"
|
| 177 |
print (e)
|
|
@@ -216,7 +217,7 @@ with gr.Blocks() as app:
|
|
| 216 |
clear_btn = gr.Button("Clear")
|
| 217 |
with gr.Row():
|
| 218 |
data=gr.Textbox(label="Input Data (paste text)", lines=6)
|
| 219 |
-
file=gr.
|
| 220 |
#text=gr.JSON()
|
| 221 |
#inp_query.change(search_models,inp_query,models_dd)
|
| 222 |
clear_btn.click(clear_fn,None,[prompt,chatbot])
|
|
|
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
+
def summarize(inp,history,data=None,files=None):
|
| 158 |
if inp == "":
|
| 159 |
inp = "Summarize this data"
|
| 160 |
|
|
|
|
| 163 |
yield "",history
|
| 164 |
if file:
|
| 165 |
try:
|
| 166 |
+
for i, file in enumerate(files):
|
| 167 |
+
print (file)
|
| 168 |
+
if file.endswith(".pdf"):
|
| 169 |
+
zz=read_pdf(file)
|
| 170 |
+
print (zz)
|
| 171 |
+
data=f'{data}\nFile Name ({file}):\n{zz}'
|
| 172 |
+
elif file.endswith(".txt"):
|
| 173 |
+
zz=read_txt(file)
|
| 174 |
+
print (zz)
|
| 175 |
+
data=f'{data}\nFile Name ({file}):\n{zz}'
|
| 176 |
except Exception as e:
|
| 177 |
data = "Error"
|
| 178 |
print (e)
|
|
|
|
| 217 |
clear_btn = gr.Button("Clear")
|
| 218 |
with gr.Row():
|
| 219 |
data=gr.Textbox(label="Input Data (paste text)", lines=6)
|
| 220 |
+
file=gr.Files(label="Input File (.pdf .txt)")
|
| 221 |
#text=gr.JSON()
|
| 222 |
#inp_query.change(search_models,inp_query,models_dd)
|
| 223 |
clear_btn.click(clear_fn,None,[prompt,chatbot])
|