Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 179 |
-
download_json_btn.click(
|
| 180 |
-
download_csv_btn.click(
|
| 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
|