Nolan Zandi commited on
Commit
4865a6a
·
1 Parent(s): 86d1010

updates to chart generation

Browse files
Files changed (2) hide show
  1. __init__.py +0 -3
  2. functions/chart_functions.py +11 -4
__init__.py DELETED
@@ -1,3 +0,0 @@
1
- from .app import data_url
2
-
3
- __all__ = ["data_url"]
 
 
 
 
functions/chart_functions.py CHANGED
@@ -22,13 +22,18 @@ def chart_generation_func(data: List[dict], session_hash: str, layout: Dict[str,
22
  #Processing data to account for variation from LLM
23
  data_list = []
24
  layout_dict = {}
 
25
  if isinstance(data, list):
26
- data_list = data
 
 
 
 
 
27
  else:
28
- data_list.append(data)
29
 
30
- if isinstance(data[0], str):
31
- data_list[0] = ast.literal_eval(data_list[0])
32
 
33
  if isinstance(layout, list):
34
  layout_obj = layout[0]
@@ -53,6 +58,7 @@ def chart_generation_func(data: List[dict], session_hash: str, layout: Dict[str,
53
 
54
  except Exception as e:
55
  print("CHART ERROR")
 
56
  reply = f"""There was an error generating the Plotly Chart from {data} and {layout}
57
  The error is {e},
58
  You should probably try again.
@@ -89,6 +95,7 @@ def table_generation_func(data: List[dict], session_hash):
89
 
90
  except Exception as e:
91
  print("TABLE ERROR")
 
92
  reply = f"""There was an error generating the Pandas DataFrame table from {data}
93
  The error is {e},
94
  You should probably try again.
 
22
  #Processing data to account for variation from LLM
23
  data_list = []
24
  layout_dict = {}
25
+
26
  if isinstance(data, list):
27
+ data_obj = data[0]
28
+ else:
29
+ data_obj = data
30
+
31
+ if isinstance(data_obj, str):
32
+ data_dict = ast.literal_eval(data_obj)
33
  else:
34
+ data_dict = data_obj
35
 
36
+ data_list.append(data_dict)
 
37
 
38
  if isinstance(layout, list):
39
  layout_obj = layout[0]
 
58
 
59
  except Exception as e:
60
  print("CHART ERROR")
61
+ print(e)
62
  reply = f"""There was an error generating the Plotly Chart from {data} and {layout}
63
  The error is {e},
64
  You should probably try again.
 
95
 
96
  except Exception as e:
97
  print("TABLE ERROR")
98
+ print(e)
99
  reply = f"""There was an error generating the Pandas DataFrame table from {data}
100
  The error is {e},
101
  You should probably try again.