Omnibus commited on
Commit
bbf23c6
·
verified ·
1 Parent(s): e716f0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -424,6 +424,7 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
424
  yield "",history,chart_out,chart_out,json_box
425
 
426
  if pdf_batch.startswith("http"):
 
427
  c=0
428
  data=""
429
  for i in str(pdf_batch):
@@ -441,14 +442,20 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
441
  #data=f'{data}\nError reading URL ({batch_url})'
442
 
443
  if directory:
 
 
444
  for ea in directory:
445
  print(ea)
446
 
447
  if pdf_url.startswith("http"):
 
 
448
  print("PDF_URL")
449
  out = read_pdf_online(pdf_url)
450
  data=out
451
  if url.startswith("http"):
 
 
452
  val, out = find_all(url)
453
  if not val:
454
  data="Error"
@@ -456,6 +463,8 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
456
  else:
457
  data=out
458
  if files:
 
 
459
  for i, file in enumerate(files):
460
  try:
461
  print (file)
@@ -469,8 +478,14 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
469
  data=f'{data}\nFile Name ({file}):\n{zz}'
470
  except Exception as e:
471
  data=f'{data}\nError opening File Name ({file})'
472
- print (e)
 
 
473
  if data != "Error" and data != "":
 
 
 
 
474
  print(inp)
475
  out = str(data)
476
  rl = len(out)
@@ -486,6 +501,11 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
486
  json_out=format_json(json_out)
487
  except Exception as e:
488
  print (e)
 
 
 
 
 
489
  chart_out = get_chart(str(json_out))
490
  chart_list=chart_out.split("\n")
491
  go=True
 
424
  yield "",history,chart_out,chart_out,json_box
425
 
426
  if pdf_batch.startswith("http"):
427
+ lab="PDF Batch"
428
  c=0
429
  data=""
430
  for i in str(pdf_batch):
 
442
  #data=f'{data}\nError reading URL ({batch_url})'
443
 
444
  if directory:
445
+ lab="Directory"
446
+
447
  for ea in directory:
448
  print(ea)
449
 
450
  if pdf_url.startswith("http"):
451
+ lab="PDF URL"
452
+
453
  print("PDF_URL")
454
  out = read_pdf_online(pdf_url)
455
  data=out
456
  if url.startswith("http"):
457
+ lab="Raw HTML"
458
+
459
  val, out = find_all(url)
460
  if not val:
461
  data="Error"
 
463
  else:
464
  data=out
465
  if files:
466
+ lab="Files"
467
+
468
  for i, file in enumerate(files):
469
  try:
470
  print (file)
 
478
  data=f'{data}\nFile Name ({file}):\n{zz}'
479
  except Exception as e:
480
  data=f'{data}\nError opening File Name ({file})'
481
+ print (e)
482
+
483
+
484
  if data != "Error" and data != "":
485
+ history.clear()
486
+ history = [(inp,f"{lab}: Loaded, processing...")]
487
+ yield "",history,chart_out,chart_out,json_box
488
+
489
  print(inp)
490
  out = str(data)
491
  rl = len(out)
 
501
  json_out=format_json(json_out)
502
  except Exception as e:
503
  print (e)
504
+ history.clear()
505
+ history = [(inp,json_out),(None,"Building Chart...")]
506
+ yield "",history,chart_out,chart_out,json_box
507
+
508
+
509
  chart_out = get_chart(str(json_out))
510
  chart_list=chart_out.split("\n")
511
  go=True