Omnibus commited on
Commit
29d9b22
·
verified ·
1 Parent(s): 242e308

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -14,6 +14,7 @@ import uuid
14
  #from query import tasks
15
  from agent import (
16
  PREFIX,
 
17
  COMPRESS_DATA_PROMPT,
18
  COMPRESS_DATA_PROMPT_SMALL,
19
  LOG_PROMPT,
@@ -285,9 +286,17 @@ def compress_data_og(c, instruct, history):
285
  #history = "observation: {}\n".format(resp)
286
  return resp
287
 
288
-
289
-
290
- def summarize(inp,history,report_check,data=None,files=None,url=None,pdf_url=None,pdf_batch=None):
 
 
 
 
 
 
 
 
291
  json_box=[]
292
  if inp == "":
293
  inp = "Process this data"
@@ -375,6 +384,9 @@ def summarize(inp,history,report_check,data=None,files=None,url=None,pdf_url=Non
375
  rawp = compress_data_og(c,inp,out)
376
  else:
377
  rawp = out
 
 
 
378
  else:
379
  rawp = "Provide a valid data source"
380
  #print (rawp)
@@ -397,6 +409,7 @@ with gr.Blocks() as app:
397
  prompt=gr.Textbox(label = "Instructions (optional)")
398
  with gr.Column(scale=1):
399
  report_check=gr.Checkbox(label="Return Report", value=True)
 
400
  button=gr.Button()
401
 
402
  #models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
@@ -414,11 +427,11 @@ with gr.Blocks() as app:
414
  pdf_url = gr.Textbox(label="PDF URL")
415
  with gr.Tab("PDF Batch"):
416
  pdf_batch = gr.Textbox(label="PDF URL Batch (comma separated)")
417
- json_out=gr.JSON()
418
  e_box=gr.Textbox()
 
419
  #text=gr.JSON()
420
  #inp_query.change(search_models,inp_query,models_dd)
421
  clear_btn.click(clear_fn,None,[prompt,chatbot])
422
- go=button.click(summarize,[prompt,chatbot,report_check,data,file,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
423
  stop_button.click(None,None,None,cancels=[go])
424
  app.queue(default_concurrency_limit=20).launch(server_port=7860,show_api=False)
 
14
  #from query import tasks
15
  from agent import (
16
  PREFIX,
17
+ GET_CHART,
18
  COMPRESS_DATA_PROMPT,
19
  COMPRESS_DATA_PROMPT_SMALL,
20
  LOG_PROMPT,
 
286
  #history = "observation: {}\n".format(resp)
287
  return resp
288
 
289
+ def get_chart(inp):
290
+ seed=random.randint(1,1000000000)
291
+
292
+ resp = run_gpt(
293
+ GET_CHART,
294
+ stop_tokens=["observation:", "task:", "action:", "thought:"],
295
+ max_tokens=8192,
296
+ seed=seed,
297
+ )
298
+ return resp
299
+ def summarize(inp,history,report_check,chart_check,data=None,files=None,url=None,pdf_url=None,pdf_batch=None):
300
  json_box=[]
301
  if inp == "":
302
  inp = "Process this data"
 
384
  rawp = compress_data_og(c,inp,out)
385
  else:
386
  rawp = out
387
+ if chart_check:
388
+ error_box = get_chart(rawp)
389
+
390
  else:
391
  rawp = "Provide a valid data source"
392
  #print (rawp)
 
409
  prompt=gr.Textbox(label = "Instructions (optional)")
410
  with gr.Column(scale=1):
411
  report_check=gr.Checkbox(label="Return Report", value=True)
412
+ chart_check=gr.Checkbox(label="Return Chart", value=True)
413
  button=gr.Button()
414
 
415
  #models_dd=gr.Dropdown(choices=[m for m in return_list],interactive=True)
 
427
  pdf_url = gr.Textbox(label="PDF URL")
428
  with gr.Tab("PDF Batch"):
429
  pdf_batch = gr.Textbox(label="PDF URL Batch (comma separated)")
 
430
  e_box=gr.Textbox()
431
+ json_out=gr.JSON()
432
  #text=gr.JSON()
433
  #inp_query.change(search_models,inp_query,models_dd)
434
  clear_btn.click(clear_fn,None,[prompt,chatbot])
435
+ go=button.click(summarize,[prompt,chatbot,report_check,chart_check,data,file,url,pdf_url,pdf_batch],[prompt,chatbot,e_box,json_out])
436
  stop_button.click(None,None,None,cancels=[go])
437
  app.queue(default_concurrency_limit=20).launch(server_port=7860,show_api=False)