Omnibus commited on
Commit
2f373b5
·
1 Parent(s): 7f6ba54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -42
app.py CHANGED
@@ -156,52 +156,54 @@ def compress_data(c, instruct, history):
156
 
157
  def summarize(inp,history,data=None,file=None):
158
  #file = None
159
-
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
  #################################
203
  def clear_fn():
204
- return "",[("","")]
205
 
206
  with gr.Blocks() as app:
207
  gr.HTML("""<center><h1>Mixtral 8x7B TLDR Summarizer</h1><h3>Summarize Data of unlimited length</h3>""")
 
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)]
207
 
208
  with gr.Blocks() as app:
209
  gr.HTML("""<center><h1>Mixtral 8x7B TLDR Summarizer</h1><h3>Summarize Data of unlimited length</h3>""")