Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -188,14 +188,17 @@ def save_story(chat_history):
|
|
188 |
if not chat_history:
|
189 |
return None
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
199 |
|
200 |
# Add this function to get a custom avatar image URL
|
201 |
def get_storyteller_avatar_url():
|
@@ -212,9 +215,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
212 |
You lead the way with your choices, and AI responds, expanding on your ideas.
|
213 |
|
214 |
### How to Play:
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
218 |
|
219 |
> **Tip:** The more detail you provide, the deeper the story becomes.
|
220 |
""")
|
@@ -337,11 +341,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
337 |
story_output = gr.File(
|
338 |
label="Download your story",
|
339 |
file_count="single",
|
340 |
-
file_types=[".md"]
|
|
|
341 |
)
|
342 |
|
343 |
save_btn.click(
|
344 |
-
fn=
|
345 |
inputs=[chatbot],
|
346 |
outputs=[story_output]
|
347 |
)
|
|
|
188 |
if not chat_history:
|
189 |
return None
|
190 |
|
191 |
+
try:
|
192 |
+
story_text = "# My Interactive Adventure\n\n"
|
193 |
+
# Process chat history (already in tuples of user, bot messages)
|
194 |
+
for user_msg, bot_msg in chat_history:
|
195 |
+
story_text += f"**Player:** {user_msg}\n\n"
|
196 |
+
story_text += f"**Story:** {bot_msg}\n\n---\n\n"
|
197 |
+
|
198 |
+
return {"name": "my_adventure.md", "data": story_text.encode('utf-8')}
|
199 |
+
except Exception as e:
|
200 |
+
logging.error(f"Error saving story: {e}")
|
201 |
+
return None
|
202 |
|
203 |
# Add this function to get a custom avatar image URL
|
204 |
def get_storyteller_avatar_url():
|
|
|
215 |
You lead the way with your choices, and AI responds, expanding on your ideas.
|
216 |
|
217 |
### How to Play:
|
218 |
+
* Pick a genre that sparks your imagination
|
219 |
+
* Choose a Story Starter or start from scratch
|
220 |
+
* Work with AI—describe your actions, make decisions, and see how the story unfolds together
|
221 |
+
|
222 |
|
223 |
> **Tip:** The more detail you provide, the deeper the story becomes.
|
224 |
""")
|
|
|
341 |
story_output = gr.File(
|
342 |
label="Download your story",
|
343 |
file_count="single",
|
344 |
+
file_types=[".md"],
|
345 |
+
interactive=False
|
346 |
)
|
347 |
|
348 |
save_btn.click(
|
349 |
+
fn=save_story,
|
350 |
inputs=[chatbot],
|
351 |
outputs=[story_output]
|
352 |
)
|