petrified commited on
Commit
8732eae
·
verified ·
1 Parent(s): bbb6ae4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
app.py CHANGED
@@ -134,27 +134,22 @@ def random_response(message, history):
134
  summary = lida.summarize(df_data)
135
 
136
  print(f'*'*50)
137
- goals = lida.goals(summary, n=1, textgen_config=text_gen_config,persona=f'Use color RoyalBlue#4169E1 for the line or bar.Show the average value line.An data analyst of the company who want to know {question}')
138
 
139
  # ValueError: Unsupported library. Choose from 'matplotlib', 'seaborn', 'plotly', 'bokeh', 'ggplot', 'altair'.
 
 
 
 
 
 
 
 
 
140
 
141
- chart_result = []
142
-
143
- final_explanation = []
144
-
145
- for i in range(1):
146
- try:
147
- print(f"Goal{i}: {goals[i]}")
148
- temp_chart = lida.visualize(summary=summary, goal=goals[i], textgen_config=text_gen_config,library='plotly')
149
- temp_explanation = lida.explain(code=temp_chart[0].code)
150
- final_explanation.append(temp_explanation)
151
- chart_result.append(temp_chart)
152
- except Exception as e:
153
- print(f"Error while: {e}")
154
- for i in range(len(chart_result)):
155
- chart_result[i][0].savefig(f'chart_{i}.png')
156
- print(f'*'*50)
157
- print(f"Chart {i} saved")
158
 
159
  # Path to your image
160
  image_path = "chart_0.png"
@@ -195,7 +190,7 @@ with gr.Blocks() as demo:
195
  chat_output = gr.Textbox(label="Response", interactive=False)
196
 
197
  examples = gr.Examples(
198
- examples=['Top 10 prod_cate sales rank', 'Top product in category Seafood','Sum sales trend of product name called Lobster by time per day'],
199
  inputs=chat_input
200
  )
201
 
 
134
  summary = lida.summarize(df_data)
135
 
136
  print(f'*'*50)
137
+ goals = lida.goals(summary, n=1, textgen_config=text_gen_config,persona=f'An data analyst of the company who want to know {question}')
138
 
139
  # ValueError: Unsupported library. Choose from 'matplotlib', 'seaborn', 'plotly', 'bokeh', 'ggplot', 'altair'.
140
+ print(f'goals: {goals[0]}')
141
+
142
+ try:
143
+ temp_chart = lida.visualize(summary=summary, goal=goals[0].question+'set different color to the graph', textgen_config=text_gen_config,library='plotly')
144
+ # code = temp_chart[0].code
145
+ # instructions = ["change the color of the graph to #4169E1 if there is only one variable","change the background color to white but keep the grid lines grey","set the average line for the graph to be red"]
146
+ # edited_chart = lida.edit(code=code,summary=summary,instructions=instructions,library='plotly',textgen_config = text_gen_config)
147
+ except Exception as e:
148
+ print(f"Error while: {e}")
149
 
150
+ temp_chart[0].savefig(f'chart_0.png')
151
+ print(f'*'*50)
152
+ print(f"Chart saved")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  # Path to your image
155
  image_path = "chart_0.png"
 
190
  chat_output = gr.Textbox(label="Response", interactive=False)
191
 
192
  examples = gr.Examples(
193
+ examples=['Top 10 prod_cate sales', 'Top product in category Seafood','Sum sales trend of product name called Lobster by time per day'],
194
  inputs=chat_input
195
  )
196