Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,12 +114,12 @@ def read_pdf_online(url):
|
|
| 114 |
#####################
|
| 115 |
try:
|
| 116 |
if response.status_code == 200:
|
| 117 |
-
with open("
|
| 118 |
f.write(response.content)
|
| 119 |
#f.close()
|
| 120 |
#out = Path("./data.pdf")
|
| 121 |
#print (out)
|
| 122 |
-
reader = PdfReader("
|
| 123 |
number_of_pages = len(reader.pages)
|
| 124 |
print(number_of_pages)
|
| 125 |
for i in range(number_of_pages):
|
|
@@ -399,8 +399,7 @@ def summarize(inp,history,data=None,files=None,url=None,pdf_url=None,pdf_batch=N
|
|
| 399 |
|
| 400 |
json_out = compress_data(c,inp,out)
|
| 401 |
#json_box.append(json_out)
|
| 402 |
-
|
| 403 |
-
yield "", history,error_box,json_out
|
| 404 |
|
| 405 |
#json_object = json.dumps(eval(json_out), indent=4)
|
| 406 |
#json_box.append(json_out)
|
|
@@ -419,9 +418,12 @@ def summarize(inp,history,data=None,files=None,url=None,pdf_url=None,pdf_batch=N
|
|
| 419 |
if i == " " or i=="," or i=="\n":
|
| 420 |
c +=1
|
| 421 |
print (f'c2:: {c}')
|
| 422 |
-
|
|
|
|
| 423 |
json_final=compress_data_json(c,inp,out)
|
| 424 |
-
|
|
|
|
|
|
|
| 425 |
|
| 426 |
rawp = compress_data_og(c,inp,out)
|
| 427 |
else:
|
|
@@ -430,7 +432,7 @@ def summarize(inp,history,data=None,files=None,url=None,pdf_url=None,pdf_batch=N
|
|
| 430 |
#print (f'out:: {out}')
|
| 431 |
#history += "observation: the search results are:\n {}\n".format(out)
|
| 432 |
#task = "complete?"
|
| 433 |
-
history.clear()
|
| 434 |
history.append((inp,rawp))
|
| 435 |
yield "", history,error_box,json_final
|
| 436 |
|
|
|
|
| 114 |
#####################
|
| 115 |
try:
|
| 116 |
if response.status_code == 200:
|
| 117 |
+
with open(f"{uid}-pdf-online.pdf", "wb") as f:
|
| 118 |
f.write(response.content)
|
| 119 |
#f.close()
|
| 120 |
#out = Path("./data.pdf")
|
| 121 |
#print (out)
|
| 122 |
+
reader = PdfReader(f"{uid}-pdf-online.pdf")
|
| 123 |
number_of_pages = len(reader.pages)
|
| 124 |
print(number_of_pages)
|
| 125 |
for i in range(number_of_pages):
|
|
|
|
| 399 |
|
| 400 |
json_out = compress_data(c,inp,out)
|
| 401 |
#json_box.append(json_out)
|
| 402 |
+
|
|
|
|
| 403 |
|
| 404 |
#json_object = json.dumps(eval(json_out), indent=4)
|
| 405 |
#json_box.append(json_out)
|
|
|
|
| 418 |
if i == " " or i=="," or i=="\n":
|
| 419 |
c +=1
|
| 420 |
print (f'c2:: {c}')
|
| 421 |
+
history.append(("",out))
|
| 422 |
+
yield "", history,error_box,out
|
| 423 |
json_final=compress_data_json(c,inp,out)
|
| 424 |
+
json_final = str(json_final)
|
| 425 |
+
#history.append(("",out))
|
| 426 |
+
yield "", history,error_box,json_final
|
| 427 |
|
| 428 |
rawp = compress_data_og(c,inp,out)
|
| 429 |
else:
|
|
|
|
| 432 |
#print (f'out:: {out}')
|
| 433 |
#history += "observation: the search results are:\n {}\n".format(out)
|
| 434 |
#task = "complete?"
|
| 435 |
+
#history.clear()
|
| 436 |
history.append((inp,rawp))
|
| 437 |
yield "", history,error_box,json_final
|
| 438 |
|