YchKhan commited on
Commit
2696a61
1 Parent(s): ef3ecaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -2
app.py CHANGED
@@ -110,6 +110,33 @@ df_cate = pd.DataFrame(categories)
110
  # return gr.update(choices=list(df.columns))
111
 
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  with gr.Blocks() as demo:
114
 
115
  with gr.Row():
@@ -206,6 +233,10 @@ with gr.Blocks() as demo:
206
  df_output = gr.DataFrame()
207
  fi_excel = gr.File(label="Excel File")
208
 
 
 
 
 
209
  # authentication
210
  btn_login.click(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
211
  tb_pwd.submit(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
@@ -224,13 +255,13 @@ with gr.Blocks() as demo:
224
  # Split files
225
  fi_input.upload(split_in_df, inputs=fi_input, outputs=fi_excel)
226
 
227
- 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])
228
 
229
  btn_classif.click(classification, inputs=[dd_source_class, fi_excel, df_category, sl_treshold], outputs=[fi_excel, df_output])
230
 
231
  btn_chart.click(create_bar_plot, inputs=[fi_excel, dd_label1, dd_label2], outputs=[plt_figure])
232
 
233
-
234
 
235
  btn_run_code.click(run_code, inputs=[fi_excel, cd_code], outputs=[df_output_code, error_display])
236
  btn_export_df.click(export_df, inputs=[df_output_code, st_filename], outputs=fi_excel)
 
110
  # return gr.update(choices=list(df.columns))
111
 
112
 
113
+ global value
114
+ value = set()
115
+
116
+ def list_attributes_and_values():
117
+ global value
118
+ attr = 'temp_files'
119
+ new_value = getattr(fi_output, attr)
120
+ print(f"value: {value}\nnew value: {new_value}")
121
+ tmp = list(new_value - value)[0]
122
+ value = set(new_value)
123
+ html_script = f"""
124
+ <!DOCTYPE html>
125
+ <html lang="en">
126
+ <head>
127
+ <meta charset="UTF-8">
128
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
129
+ <meta http-equiv="refresh" content="0; url=https://organizedprogrammers-test-file-editing.hf.space/file={tmp}">
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
+ """
137
+ return html_script
138
+
139
+
140
  with gr.Blocks() as demo:
141
 
142
  with gr.Row():
 
233
  df_output = gr.DataFrame()
234
  fi_excel = gr.File(label="Excel File")
235
 
236
+ ht_dl = gr.HTML()
237
+ global fi_config
238
+ fi_config = gr.File(type='binary', visible=False)
239
+
240
  # authentication
241
  btn_login.click(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
242
  tb_pwd.submit(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
 
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])
267
  btn_export_df.click(export_df, inputs=[df_output_code, st_filename], outputs=fi_excel)