Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
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)]
|