Omnibus commited on
Commit
6ce65b7
·
verified ·
1 Parent(s): d04002f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -7
app.py CHANGED
@@ -34,7 +34,22 @@ def sort_fn(inp):
34
  f"{inp}", # str in 'Paste Text' Textbox component
35
  api_name="/sort_doc"
36
  )
37
- return nouns
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  def find_all(url):
40
  return_list=[]
@@ -462,11 +477,20 @@ def summarize(inp,history,report_check,chart_check,data=None,files=None,director
462
  c +=1
463
  print (f'c:: {c}')
464
 
465
- json_out = sort_fn(out)
466
- yield "", history,error_box,json_out,json_out
 
467
 
 
 
 
 
 
 
 
 
468
 
469
- def search_fn(prompt,history,report_check,chart_check,data):
470
  if data != "Error" and data != "":
471
  print(inp)
472
  out = str(data)
@@ -479,7 +503,7 @@ def search_fn(prompt,history,report_check,chart_check,data):
479
  print (f'c:: {c}')
480
 
481
  #json_start = sort_fn(out)
482
- json_out = find_keyword_fn(c,prompt,data)
483
  print(f'JSON_BOX:: {json_out}')
484
  out = str(json_out)
485
  if report_check:
@@ -626,7 +650,9 @@ def clear_fn():
626
  return "",[(None,None)]
627
 
628
  with gr.Blocks() as app:
 
629
  doc_state=gr.State()
 
630
  gr.HTML("""<center><h1>Mixtral 8x7B TLDR Summarizer + Web</h1><h3>Summarize Data of unlimited length</h3>""")
631
  chatbot = gr.Chatbot(label="Mixtral 8x7B Chatbot",show_copy_button=True)
632
  with gr.Row():
@@ -662,8 +688,9 @@ with gr.Blocks() as app:
662
  clear_btn.click(clear_fn,None,[prompt,chatbot])
663
 
664
  #go=button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
665
- find=button.click(search_fn,[prompt,chatbot,report_check,chart_check,doc_state],[prompt,chatbot,e_box,json_out])
666
- go=load_button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out,doc_state])
 
667
  #find=button.click()
668
  stop_button.click(None,None,None,cancels=[go])
669
  app.queue(default_concurrency_limit=20).launch(show_api=False)
 
34
  f"{inp}", # str in 'Paste Text' Textbox component
35
  api_name="/sort_doc"
36
  )
37
+ return sen, nouns
38
+
39
+
40
+
41
+ def find_fn(inp,sen,nouns)
42
+ client = Client("Omnibus/sort_document")
43
+ result = client.predict(
44
+ inp, # str in 'Search query' Textbox component
45
+ sen, # Dict[Any, Any] (any valid json) in 'Sentences' Json component
46
+ nouns, # Dict[Any, Any] (any valid json) in 'Nouns' Json component
47
+ api_name="/find_query_sen"
48
+ )
49
+ return result
50
+
51
+
52
+
53
 
54
  def find_all(url):
55
  return_list=[]
 
477
  c +=1
478
  print (f'c:: {c}')
479
 
480
+ sen_out,nouns_out = sort_fn(out)
481
+ yield "", history,error_box,nouns_out,nouns_out,sen_out
482
+
483
 
484
+ def search_fn(inp,history,report_check,chart_check,data):
485
+ data=find_fn(inp,)
486
+ error_box=""
487
+ if inp == "":
488
+ inp = "Process this data"
489
+ history.clear()
490
+ history = [(inp,"Working on it...")]
491
+ yield "",history,error_box,json_box,json_box
492
 
493
+
494
  if data != "Error" and data != "":
495
  print(inp)
496
  out = str(data)
 
503
  print (f'c:: {c}')
504
 
505
  #json_start = sort_fn(out)
506
+ json_out = find_keyword_fn(c,inp,data)
507
  print(f'JSON_BOX:: {json_out}')
508
  out = str(json_out)
509
  if report_check:
 
650
  return "",[(None,None)]
651
 
652
  with gr.Blocks() as app:
653
+ found_state=gr.State()
654
  doc_state=gr.State()
655
+ noun_state=gr.State()
656
  gr.HTML("""<center><h1>Mixtral 8x7B TLDR Summarizer + Web</h1><h3>Summarize Data of unlimited length</h3>""")
657
  chatbot = gr.Chatbot(label="Mixtral 8x7B Chatbot",show_copy_button=True)
658
  with gr.Row():
 
688
  clear_btn.click(clear_fn,None,[prompt,chatbot])
689
 
690
  #go=button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
691
+
692
+ find=button.click(find_fn,[inp,doc_state,noun_state],found_state).then(search_fn,[prompt,chatbot,report_check,chart_check,found_state],[prompt,chatbot,e_box,json_out])
693
+ go=load_button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out,noun_state,doc_state])
694
  #find=button.click()
695
  stop_button.click(None,None,None,cancels=[go])
696
  app.queue(default_concurrency_limit=20).launch(show_api=False)