melk2025 commited on
Commit
6ac8964
·
verified ·
1 Parent(s): f3a372e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -270,6 +270,7 @@ def chatbot(query):
270
  #demo.queue()
271
  #demo.launch(share=False)
272
  # Initialize chat history with a welcome message
 
273
 
274
  def save_chat_to_file(chat_history):
275
  timestamp = time.strftime("%Y%m%d-%H%M%S")
@@ -277,9 +278,12 @@ def save_chat_to_file(chat_history):
277
 
278
  # Prepare the file content
279
  file_content = json.dumps(chat_history, ensure_ascii=False, indent=2)
280
-
281
- # Return the file as a download link
282
- return (filename, file_content)
 
 
 
283
 
284
  def ask(user_message, chat_history):
285
  if not user_message:
 
270
  #demo.queue()
271
  #demo.launch(share=False)
272
  # Initialize chat history with a welcome message
273
+ import io
274
 
275
  def save_chat_to_file(chat_history):
276
  timestamp = time.strftime("%Y%m%d-%H%M%S")
 
278
 
279
  # Prepare the file content
280
  file_content = json.dumps(chat_history, ensure_ascii=False, indent=2)
281
+
282
+ # Create an in-memory file (using io.BytesIO or io.StringIO)
283
+ file_obj = io.StringIO(file_content)
284
+
285
+ # Return the file object and filename so Gradio can process it
286
+ return (filename, file_obj)
287
 
288
  def ask(user_message, chat_history):
289
  if not user_message: