Omnibus commited on
Commit
33fa1b3
·
1 Parent(s): 2f373b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -44
app.py CHANGED
@@ -155,52 +155,48 @@ def compress_data(c, instruct, history):
155
 
156
 
157
  def summarize(inp,history,data=None,file=None):
158
- #file = None
159
- try:
160
 
161
- if inp == "":
162
- inp = "Process this data"
163
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- history = [(inp,"Working on it...")] if not history else history
166
- yield "",history
167
- if file:
168
- try:
169
- print (file)
170
- if file.endswith(".pdf"):
171
- zz=read_pdf(file)
172
- print (zz)
173
- data=f'{data}\nFile:\n{zz}'
174
- elif file.endswith(".txt"):
175
- zz=read_txt(file)
176
- print (zz)
177
- data=f'{data}\nFile:\n{zz}'
178
- except Exception as e:
179
- data = "Error"
180
- print (e)
181
- if not data == "Error":
182
- print(inp)
183
- out = str(data)
184
- rl = len(out)
185
- print(f'rl:: {rl}')
186
- c=0
187
- for i in str(out):
188
- if i == " " or i=="," or i=="\n":
189
- c +=1
190
- print (f'c:: {c}')
191
-
192
- rawp = compress_data(c,inp,out)
193
- else:
194
- rawp = "Error"
195
- #print (rawp)
196
- #print (f'out:: {out}')
197
- #history += "observation: the search results are:\n {}\n".format(out)
198
- #task = "complete?"
199
- history.clear()
200
- history.append((inp,rawp))
201
- yield "", history
202
- except Exception:
203
- yield "", ["","Provide valid input"]
204
  #################################
205
  def clear_fn():
206
  return "",[(None,None)]
 
155
 
156
 
157
  def summarize(inp,history,data=None,file=None):
158
+ if inp == "":
159
+ inp = "Process this data"
160
 
161
+
162
+ history = [(inp,"Working on it...")] if not history else history
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)
178
+ if not data == "Error":
179
+ print(inp)
180
+ out = str(data)
181
+ rl = len(out)
182
+ print(f'rl:: {rl}')
183
+ c=0
184
+ for i in str(out):
185
+ if i == " " or i=="," or i=="\n":
186
+ c +=1
187
+ print (f'c:: {c}')
188
 
189
+ rawp = compress_data(c,inp,out)
190
+ else:
191
+ rawp = "Error"
192
+ #print (rawp)
193
+ #print (f'out:: {out}')
194
+ #history += "observation: the search results are:\n {}\n".format(out)
195
+ #task = "complete?"
196
+ history.clear()
197
+ history.append((inp,rawp))
198
+ yield "", history
199
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  #################################
201
  def clear_fn():
202
  return "",[(None,None)]