Omnibus commited on
Commit
6971ec3
1 Parent(s): b0b3b63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -314,6 +314,35 @@ def get_chart(inp):
314
  print(f'Error:: {e}')
315
  resp = e
316
  return resp
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  def summarize(inp,history,report_check,chart_check,data=None,files=None,directory=None,url=None,pdf_url=None,pdf_batch=None):
318
  json_box=[]
319
  error_box=""
@@ -405,9 +434,13 @@ def summarize(inp,history,report_check,chart_check,data=None,files=None,director
405
  rawp = compress_data_og(c,inp,out)
406
  else:
407
  rawp = out
 
 
 
 
408
  if chart_check:
409
  print (f"making chart from ::: {rawp}")
410
- error_box = get_chart(str(rawp))
411
  print(error_box)
412
  else:
413
  rawp = "Provide a valid data source"
 
314
  print(f'Error:: {e}')
315
  resp = e
316
  return resp
317
+
318
+ def format_json(inp):
319
+
320
+ print("FORMATTING:::")
321
+ print(type(inp))
322
+ print("###########")
323
+ print(inp)
324
+ print("###########")
325
+ print("###########")
326
+ new_str=""
327
+ matches=["```","#","//"]
328
+ for i,line in enumerate(inp):
329
+ line = line.strip()
330
+ print(line)
331
+ #if not any(x in line for x in matches):
332
+ new_str+=line.strip("\n").strip("```").strip("#").strip("//")
333
+ print("###########")
334
+ print("###########")
335
+ #inp = inp.strip("<\s>")
336
+ new_str=new_str.strip("</s>")
337
+ out_json=eval(new_str)
338
+ print(out_json)
339
+ print("###########")
340
+ print("###########")
341
+
342
+ return out_json
343
+
344
+
345
+
346
  def summarize(inp,history,report_check,chart_check,data=None,files=None,directory=None,url=None,pdf_url=None,pdf_batch=None):
347
  json_box=[]
348
  error_box=""
 
434
  rawp = compress_data_og(c,inp,out)
435
  else:
436
  rawp = out
437
+ try:
438
+ json_out=format_json(json_out)
439
+ except Exception as e:
440
+ print (e)
441
  if chart_check:
442
  print (f"making chart from ::: {rawp}")
443
+ error_box = get_chart(str(json_out))
444
  print(error_box)
445
  else:
446
  rawp = "Provide a valid data source"