igortech commited on
Commit
b4686d0
·
verified ·
1 Parent(s): d89e92d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -165,19 +165,23 @@ with gr.Blocks() as demo:
165
  with gr.Row():
166
  upload_btn = gr.File(label="Upload dataset (.json)", file_types=[".json"], type="filepath")
167
  upload_status = gr.Textbox(label="Upload status", interactive=False)
168
- download_json_btn = gr.File(label="Download current dataset (.json)")
169
- download_csv_btn = gr.File(label="Export conversation to CSV")
 
 
 
 
 
170
 
171
  # Events
172
  msg.submit(respond, [msg, chatbot, category], [msg, chatbot])
173
  send.click(respond, [msg, chatbot, category], [msg, chatbot])
174
  clear.click(clear_chat, None, chatbot, queue=False)
175
-
176
  upload_btn.upload(upload_json, upload_btn, [upload_status, category])
177
 
178
- # Fixed downloads using click with component inputs
179
- download_json_btn.click(lambda: download_current_json(), inputs=None, outputs=download_json_btn)
180
- download_csv_btn.click(lambda history: download_conversation_csv(history), inputs=chatbot, outputs=download_csv_btn)
181
 
182
  # -----------------------------
183
  # Startup log
 
165
  with gr.Row():
166
  upload_btn = gr.File(label="Upload dataset (.json)", file_types=[".json"], type="filepath")
167
  upload_status = gr.Textbox(label="Upload status", interactive=False)
168
+
169
+ # New download system
170
+ with gr.Row():
171
+ download_json_btn = gr.Button("Download current dataset (.json)")
172
+ download_csv_btn = gr.Button("Export conversation to CSV")
173
+ download_json_file = gr.File(label="JSON download")
174
+ download_csv_file = gr.File(label="CSV download")
175
 
176
  # Events
177
  msg.submit(respond, [msg, chatbot, category], [msg, chatbot])
178
  send.click(respond, [msg, chatbot, category], [msg, chatbot])
179
  clear.click(clear_chat, None, chatbot, queue=False)
 
180
  upload_btn.upload(upload_json, upload_btn, [upload_status, category])
181
 
182
+ # Fixed download events using Button -> File
183
+ download_json_btn.click(fn=download_current_json, inputs=None, outputs=download_json_file)
184
+ download_csv_btn.click(fn=download_conversation_csv, inputs=chatbot, outputs=download_csv_file)
185
 
186
  # -----------------------------
187
  # Startup log