Omnibus commited on
Commit
cd2eac7
·
1 Parent(s): 2192ac7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -154,7 +154,7 @@ def compress_data(c, instruct, history):
154
 
155
 
156
 
157
- def summarize(inp,history,data=None,file=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
- print (file)
167
- if file.endswith(".pdf"):
168
- zz=read_pdf(file)
169
- print (zz)
170
- data=f'{data}\nFile:\n{zz}'
171
- elif file.endswith(".txt"):
172
- zz=read_txt(file)
173
- print (zz)
174
- data=f'{data}\nFile:\n{zz}'
 
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.File(label="Input File (.pdf .txt)")
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])