Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -131,6 +131,8 @@ class StorytellerWorkflow(Workflow):
|
|
| 131 |
# --- Gradio UI and Application Logic ---
|
| 132 |
# This is the final, correct version of the main application logic function.
|
| 133 |
|
|
|
|
|
|
|
| 134 |
async def run_turn(user_input, game_state):
|
| 135 |
# game_state is now a dictionary: {'inventory': [], 'last_story_part': None}
|
| 136 |
|
|
@@ -146,14 +148,14 @@ async def run_turn(user_input, game_state):
|
|
| 146 |
# 1. Create a fresh workflow instance for this turn
|
| 147 |
workflow = StorytellerWorkflow()
|
| 148 |
|
| 149 |
-
# 2. Create
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
|
| 156 |
-
#
|
| 157 |
result_event = await workflow.generate_story_part(event, ctx)
|
| 158 |
# ---
|
| 159 |
|
|
|
|
| 131 |
# --- Gradio UI and Application Logic ---
|
| 132 |
# This is the final, correct version of the main application logic function.
|
| 133 |
|
| 134 |
+
# This is the final, correct version of the main application logic function.
|
| 135 |
+
|
| 136 |
async def run_turn(user_input, game_state):
|
| 137 |
# game_state is now a dictionary: {'inventory': [], 'last_story_part': None}
|
| 138 |
|
|
|
|
| 148 |
# 1. Create a fresh workflow instance for this turn
|
| 149 |
workflow = StorytellerWorkflow()
|
| 150 |
|
| 151 |
+
# 2. Create an empty context object
|
| 152 |
+
ctx = Context()
|
| 153 |
+
|
| 154 |
+
# 3. Asynchronously set the values in the context's store
|
| 155 |
+
await ctx.store.set("inventory", game_state['inventory'])
|
| 156 |
+
await ctx.store.set("last_story_part", game_state['last_story_part'])
|
| 157 |
|
| 158 |
+
# 4. Call the specific step method directly, passing the populated context
|
| 159 |
result_event = await workflow.generate_story_part(event, ctx)
|
| 160 |
# ---
|
| 161 |
|