PeterPinetree commited on
Commit
3780a59
·
verified ·
1 Parent(s): beb06c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -196,8 +196,8 @@ def save_story(chat_history):
196
  story_text += f"**Player:** {chat_history[i]}\n\n"
197
  story_text += f"**Story:** {chat_history[i+1]}\n\n---\n\n"
198
 
199
- # Return as a file for download
200
- return story_text
201
 
202
  # Add this function to get a custom avatar image URL
203
  def get_storyteller_avatar_url():
@@ -339,12 +339,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
339
  story_output = gr.File(
340
  label="Download your story",
341
  file_count="single",
342
- type="string",
343
  file_types=[".md"]
344
  )
345
 
346
  save_btn.click(
347
- fn=lambda x: (save_story(x), "story.md") if x else None,
348
  inputs=[chatbot],
349
  outputs=[story_output]
350
  )
 
196
  story_text += f"**Player:** {chat_history[i]}\n\n"
197
  story_text += f"**Story:** {chat_history[i+1]}\n\n---\n\n"
198
 
199
+ # Return as bytes for download
200
+ return story_text.encode('utf-8')
201
 
202
  # Add this function to get a custom avatar image URL
203
  def get_storyteller_avatar_url():
 
339
  story_output = gr.File(
340
  label="Download your story",
341
  file_count="single",
 
342
  file_types=[".md"]
343
  )
344
 
345
  save_btn.click(
346
+ fn=lambda x: {"name": "story.md", "data": save_story(x)} if x else None,
347
  inputs=[chatbot],
348
  outputs=[story_output]
349
  )