tayyab-077 commited on
Commit
81b8166
·
1 Parent(s): 2547e78

updatation

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -350,15 +350,12 @@ with gr.Blocks(title="Tayyab — Chatbot") as demo:
350
  new_chat_btn.click(new_chat, outputs=[chatbot])
351
 
352
  def export_handler(history):
353
-
354
- # Convert Gradio chatbot format → list of dicts
355
- formatted = []
356
- if history:
357
- for u, a in history:
358
- formatted.append({"role": "user", "content": u})
359
- formatted.append({"role": "assistant", "content": a})
360
-
361
- files = export_chat_files(formatted)
362
  return (
363
  gr.update(value=files.get("txt"), visible=True),
364
  gr.update(value=files.get("pdf"), visible=bool(files.get("pdf")))
 
350
  new_chat_btn.click(new_chat, outputs=[chatbot])
351
 
352
  def export_handler(history):
353
+
354
+ if not isinstance(history, list):
355
+ history = []
356
+
357
+ files = export_chat_files(history)
358
+
 
 
 
359
  return (
360
  gr.update(value=files.get("txt"), visible=True),
361
  gr.update(value=files.get("pdf"), visible=bool(files.get("pdf")))