Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -55,7 +55,8 @@ async def generate_image(prompt: str, hf_token: str) -> str | None:
|
|
55 |
print(f"Image generation failed: {e}")
|
56 |
return None
|
57 |
|
58 |
-
# The full workflow class
|
|
|
59 |
class StorytellerWorkflow(Workflow):
|
60 |
def __init__(self, **kwargs):
|
61 |
super().__init__(timeout=300, **kwargs)
|
@@ -116,6 +117,12 @@ class StorytellerWorkflow(Workflow):
|
|
116 |
await ctx.store.set("inventory", inventory)
|
117 |
return StoryContext(story_part=full_story_part, inventory=inventory, is_new_scene=is_new_scene_flag)
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
# These two steps are no longer needed, as Gradio's UI will handle the display logic.
|
120 |
# @step async def display_scene(...)
|
121 |
# @step async def get_user_choice(...)
|
|
|
55 |
print(f"Image generation failed: {e}")
|
56 |
return None
|
57 |
|
58 |
+
# The full workflow class, now with the required end_story step
|
59 |
+
|
60 |
class StorytellerWorkflow(Workflow):
|
61 |
def __init__(self, **kwargs):
|
62 |
super().__init__(timeout=300, **kwargs)
|
|
|
117 |
await ctx.store.set("inventory", inventory)
|
118 |
return StoryContext(story_part=full_story_part, inventory=inventory, is_new_scene=is_new_scene_flag)
|
119 |
|
120 |
+
# --- THIS IS THE STEP THAT WAS MISSING ---
|
121 |
+
@step
|
122 |
+
def end_story(self, ev: StoryEnd) -> StopEvent:
|
123 |
+
"""This step satisfies the workflow validator by providing a path to a StopEvent."""
|
124 |
+
return StopEvent(result=ev.final_message)
|
125 |
+
|
126 |
# These two steps are no longer needed, as Gradio's UI will handle the display logic.
|
127 |
# @step async def display_scene(...)
|
128 |
# @step async def get_user_choice(...)
|