YchKhan commited on
Commit
cee1edf
1 Parent(s): 799f319

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -110,6 +110,14 @@ df_cate = pd.DataFrame(categories)
110
  # return gr.update(choices=list(df.columns))
111
 
112
 
 
 
 
 
 
 
 
 
113
  global value
114
  value = set()
115
 
@@ -130,7 +138,7 @@ def list_attributes_and_values():
130
  <title>Redirecting to Google</title>
131
  </head>
132
  <body>
133
- <p>If you are not redirected automatically, please <a href="https://www.google.com/">click here</a>.</p>
134
  </body>
135
  </html>
136
  """
@@ -189,7 +197,9 @@ with gr.Blocks() as demo:
189
  sl_treshold = gr.Slider(minimum=0, maximum=1, value=0.45, step=0.05, label='Similarity Treshold')
190
  gr.Markdown("### The predefined categories can be modified at any time")
191
  df_category = gr.DataFrame(label='categories', value=df_cate, interactive=True)
192
- btn_classif = gr.Button("Categorize")
 
 
193
 
194
  with gr.Tab(" Personalised Charts Generation"):
195
  gr.Markdown("### This section will create a chart using two columns of your choice")
@@ -235,7 +245,7 @@ with gr.Blocks() as demo:
235
 
236
  ht_dl = gr.HTML()
237
  global fi_config
238
- fi_config = gr.File(type='binary', visible=True)
239
 
240
  # authentication
241
  btn_login.click(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
@@ -254,13 +264,18 @@ with gr.Blocks() as demo:
254
 
255
  # Split files
256
  fi_input.upload(split_in_df, inputs=fi_input, outputs=fi_excel)
257
-
 
258
  mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, dd_prompt, fi_excel, dd_url, dd_searchcol, dd_keywords, dd_llm, st_user], outputs=[fi_excel, df_output, dd_prompt, dd_keywords, st_user, fi_config])
259
-
 
260
  btn_classif.click(classification, inputs=[dd_source_class, fi_excel, df_category, sl_treshold], outputs=[fi_excel, df_output])
261
-
 
 
262
  btn_chart.click(create_bar_plot, inputs=[fi_excel, dd_label1, dd_label2], outputs=[plt_figure])
263
 
 
264
  fi_config.change(list_attributes_and_values, inputs=None, outputs=ht_dl)
265
 
266
  btn_run_code.click(run_code, inputs=[fi_excel, cd_code], outputs=[df_output_code, error_display])
 
110
  # return gr.update(choices=list(df.columns))
111
 
112
 
113
+ def reset_cate(df_category):
114
+ if df_category.equals(df_cate):
115
+ df_category = pd.DataFrame(columns=['topic', 'description', 'expert'])
116
+ else:
117
+ df_category = df_cate.copy()
118
+ return df_category
119
+
120
+
121
  global value
122
  value = set()
123
 
 
138
  <title>Redirecting to Google</title>
139
  </head>
140
  <body>
141
+ <p>If you are not redirected automatically, please <a href="https://organizedprogrammers-standard-intelligence-dev.hf.space/file={tmp}">click here</a>.</p>
142
  </body>
143
  </html>
144
  """
 
197
  sl_treshold = gr.Slider(minimum=0, maximum=1, value=0.45, step=0.05, label='Similarity Treshold')
198
  gr.Markdown("### The predefined categories can be modified at any time")
199
  df_category = gr.DataFrame(label='categories', value=df_cate, interactive=True)
200
+ with gr.Row():
201
+ btn_reset_df = gr.Button("Reset Categories")
202
+ btn_classif = gr.Button("Categorize")
203
 
204
  with gr.Tab(" Personalised Charts Generation"):
205
  gr.Markdown("### This section will create a chart using two columns of your choice")
 
245
 
246
  ht_dl = gr.HTML()
247
  global fi_config
248
+ fi_config = gr.File(type='binary', visible=False)
249
 
250
  # authentication
251
  btn_login.click(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
 
264
 
265
  # Split files
266
  fi_input.upload(split_in_df, inputs=fi_input, outputs=fi_excel)
267
+
268
+ #llm
269
  mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, dd_prompt, fi_excel, dd_url, dd_searchcol, dd_keywords, dd_llm, st_user], outputs=[fi_excel, df_output, dd_prompt, dd_keywords, st_user, fi_config])
270
+
271
+ #classification
272
  btn_classif.click(classification, inputs=[dd_source_class, fi_excel, df_category, sl_treshold], outputs=[fi_excel, df_output])
273
+ btn_reset_df.click(reset_cate, inputs=df_cate, output=df_cate)
274
+
275
+ #charts
276
  btn_chart.click(create_bar_plot, inputs=[fi_excel, dd_label1, dd_label2], outputs=[plt_figure])
277
 
278
+ #json download
279
  fi_config.change(list_attributes_and_values, inputs=None, outputs=ht_dl)
280
 
281
  btn_run_code.click(run_code, inputs=[fi_excel, cd_code], outputs=[df_output_code, error_display])