Spaces:
Sleeping
Sleeping
Commit
·
0ce5e49
1
Parent(s):
db8ecbe
updatation
Browse files
app.py
CHANGED
|
@@ -287,15 +287,33 @@ with gr.Blocks(title="Tayyab — Chatbot") as demo:
|
|
| 287 |
|
| 288 |
new_chat_btn.click(new_chat, outputs=[chatbot])
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
def export_handler(history):
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
return (
|
| 293 |
gr.update(value=files.get("txt"), visible=True),
|
| 294 |
gr.update(value=files.get("pdf"), visible=bool(files.get("pdf")))
|
| 295 |
)
|
| 296 |
|
| 297 |
export_btn.click(export_handler, inputs=[chatbot], outputs=[file_txt, file_pdf])
|
| 298 |
-
|
| 299 |
-
|
| 300 |
if __name__ == "__main__":
|
| 301 |
demo.launch()
|
|
|
|
| 287 |
|
| 288 |
new_chat_btn.click(new_chat, outputs=[chatbot])
|
| 289 |
|
| 290 |
+
# def export_handler(history):
|
| 291 |
+
# files = export_chat_files(history or [])
|
| 292 |
+
# return (
|
| 293 |
+
# gr.update(value=files.get("txt"), visible=True),
|
| 294 |
+
# gr.update(value=files.get("pdf"), visible=bool(files.get("pdf")))
|
| 295 |
+
# )
|
| 296 |
+
|
| 297 |
+
# export_btn.click(export_handler, inputs=[chatbot], outputs=[file_txt, file_pdf])
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
|
| 301 |
def export_handler(history):
|
| 302 |
+
fixed_history = []
|
| 303 |
+
|
| 304 |
+
for user_msg, bot_msg in history:
|
| 305 |
+
fixed_history.append({"role": "user", "content": user_msg})
|
| 306 |
+
fixed_history.append({"role": "assistant", "content": bot_msg})
|
| 307 |
+
|
| 308 |
+
files = export_chat_files(fixed_history)
|
| 309 |
+
|
| 310 |
return (
|
| 311 |
gr.update(value=files.get("txt"), visible=True),
|
| 312 |
gr.update(value=files.get("pdf"), visible=bool(files.get("pdf")))
|
| 313 |
)
|
| 314 |
|
| 315 |
export_btn.click(export_handler, inputs=[chatbot], outputs=[file_txt, file_pdf])
|
| 316 |
+
|
| 317 |
+
|
| 318 |
if __name__ == "__main__":
|
| 319 |
demo.launch()
|