Omnibus commited on
Commit
3ec2518
·
verified ·
1 Parent(s): 42dae28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -197,8 +197,8 @@ def run_gpt(
197
  return resp
198
 
199
 
200
- def compress_data(c, instruct, history):
201
- seed=random.randint(1,1000000000)
202
 
203
  print (c)
204
  #tot=len(purpose)
@@ -239,8 +239,8 @@ def compress_data(c, instruct, history):
239
  return out
240
 
241
 
242
- def get_chart(inp):
243
- seed=random.randint(1,1000000000)
244
  try:
245
  resp = run_gpt_no_prefix(
246
  GET_CHART,
@@ -302,7 +302,7 @@ def mm(graph,zoom):
302
  out_html=f'''<div id="wrap" style="width: 100%; height: 100%;max-height:600px; padding: 0; overflow: auto;"><iframe id="frame" src="{url}" style="width:100%; height:600px; border: 1px solid black; zoom: {str(zoom)}; -moz-transform: scale({str(zoom)}); -moz-transform-origin: 0 0;" allow="accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"></iframe></div>'''
303
  return out_html,url
304
 
305
- def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=None,pdf_batch=None):
306
  json_box=[]
307
  chart_out=""
308
  if inp == "":
@@ -383,7 +383,7 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
383
  if i == " " or i=="," or i=="\n":
384
  c +=1
385
  print (f'c:: {c}')
386
- json_out = compress_data(c,inp,out)
387
  out = str(json_out)
388
  try:
389
  json_out=format_json(json_out)
@@ -394,7 +394,7 @@ def summarize(inp,history,data=None,files=None,directory=None,url=None,pdf_url=N
394
  yield "",history,chart_out,chart_out,json_out,""
395
 
396
 
397
- chart_out = get_chart(str(json_out))
398
  chart_list=chart_out.split("\n")
399
  go=True
400
  cnti=1
@@ -483,6 +483,7 @@ with gr.Blocks() as app:
483
  with gr.Tab("PDF Batch"):
484
  pdf_batch = gr.Textbox(label="PDF URL Batch (comma separated)")
485
  m_box=gr.HTML()
 
486
  zoom_btn=gr.Slider(label="Zoom",step=0.01,minimum=0.1,maximum=20,value=1,interactive=True)
487
  e_box=gr.Textbox(interactive=True)
488
  with gr.Row():
@@ -507,7 +508,7 @@ with gr.Blocks() as app:
507
  clear_btn.click(clear_fn,None,[prompt,chatbot])
508
 
509
  #go=button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
510
- go=button.click(summarize,[prompt,chatbot,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,m_box,e_box,json_out,url_box])
511
 
512
  stop_button.click(None,None,None,cancels=[go])
513
  #app.queue(default_concurrency_limit=20).launch(show_api=False)
 
197
  return resp
198
 
199
 
200
+ def compress_data(c, instruct, history, seed):
201
+ #seed=random.randint(1,1000000000)
202
 
203
  print (c)
204
  #tot=len(purpose)
 
239
  return out
240
 
241
 
242
+ def get_chart(inp,seed):
243
+ #seed=random.randint(1,1000000000)
244
  try:
245
  resp = run_gpt_no_prefix(
246
  GET_CHART,
 
302
  out_html=f'''<div id="wrap" style="width: 100%; height: 100%;max-height:600px; padding: 0; overflow: auto;"><iframe id="frame" src="{url}" style="width:100%; height:600px; border: 1px solid black; zoom: {str(zoom)}; -moz-transform: scale({str(zoom)}); -moz-transform-origin: 0 0;" allow="accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"></iframe></div>'''
303
  return out_html,url
304
 
305
+ def summarize(inp,history,seed,data=None,files=None,directory=None,url=None,pdf_url=None,pdf_batch=None):
306
  json_box=[]
307
  chart_out=""
308
  if inp == "":
 
383
  if i == " " or i=="," or i=="\n":
384
  c +=1
385
  print (f'c:: {c}')
386
+ json_out = compress_data(c,inp,out,seed)
387
  out = str(json_out)
388
  try:
389
  json_out=format_json(json_out)
 
394
  yield "",history,chart_out,chart_out,json_out,""
395
 
396
 
397
+ chart_out = get_chart(str(json_out),seed)
398
  chart_list=chart_out.split("\n")
399
  go=True
400
  cnti=1
 
483
  with gr.Tab("PDF Batch"):
484
  pdf_batch = gr.Textbox(label="PDF URL Batch (comma separated)")
485
  m_box=gr.HTML()
486
+ seed_slider=gr.Slider(label="Seed",step=1,minimum=1,maximum=9999999999999999999,value=1,interactive=True)
487
  zoom_btn=gr.Slider(label="Zoom",step=0.01,minimum=0.1,maximum=20,value=1,interactive=True)
488
  e_box=gr.Textbox(interactive=True)
489
  with gr.Row():
 
508
  clear_btn.click(clear_fn,None,[prompt,chatbot])
509
 
510
  #go=button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
511
+ go=button.click(summarize,[prompt,chatbot,seed_slider,data,file,directory,url,pdf_url,pdf_batch],[prompt,chatbot,m_box,e_box,json_out,url_box])
512
 
513
  stop_button.click(None,None,None,cancels=[go])
514
  #app.queue(default_concurrency_limit=20).launch(show_api=False)