Abbasid commited on
Commit
2b8aa30
·
verified ·
1 Parent(s): 32570a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
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 a context object and load our game state into its store
150
- # This is how we pass the inventory and story history to the step
151
- ctx = Context(store={
152
- "inventory": game_state['inventory'],
153
- "last_story_part": game_state['last_story_part']
154
- })
155
 
156
- # 3. Call the specific step method directly
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