Spaces:
Running
Running
Georgii Savin
commited on
fix: runtime error with user choice
Browse files- src/agent/image_agent.py +1 -1
- src/agent/llm_graph.py +2 -2
- src/agent/music_agent.py +1 -1
src/agent/image_agent.py
CHANGED
|
@@ -68,7 +68,7 @@ class ChangeScene(BaseModel):
|
|
| 68 |
|
| 69 |
image_prompt_generator_llm = create_light_llm(0.1).with_structured_output(ChangeScene)
|
| 70 |
|
| 71 |
-
async def generate_image_prompt(user_hash: str, scene_description: str) -> ChangeScene:
|
| 72 |
"""
|
| 73 |
Generates a detailed image prompt string based on a scene description.
|
| 74 |
This prompt is intended for use with an AI image generation model.
|
|
|
|
| 68 |
|
| 69 |
image_prompt_generator_llm = create_light_llm(0.1).with_structured_output(ChangeScene)
|
| 70 |
|
| 71 |
+
async def generate_image_prompt(user_hash: str, scene_description: str, last_choice = "No choice yet") -> ChangeScene:
|
| 72 |
"""
|
| 73 |
Generates a detailed image prompt string based on a scene description.
|
| 74 |
This prompt is intended for use with an AI image generation model.
|
src/agent/llm_graph.py
CHANGED
|
@@ -94,7 +94,7 @@ async def node_player_step(state: GraphState) -> GraphState:
|
|
| 94 |
"last_choice": state.choice_text,
|
| 95 |
}
|
| 96 |
)
|
| 97 |
-
change_scene = await generate_image_prompt(state.user_hash, next_scene["description"])
|
| 98 |
current_image = None
|
| 99 |
if scene_id and scene_id in user_state.scenes:
|
| 100 |
current_image = user_state.scenes[scene_id].image
|
|
@@ -107,7 +107,7 @@ async def node_player_step(state: GraphState) -> GraphState:
|
|
| 107 |
"change_scene": change_scene,
|
| 108 |
}
|
| 109 |
)
|
| 110 |
-
music_task = generate_music_prompt(next_scene["description"])
|
| 111 |
_, music_prompt = await asyncio.gather(image_task, music_task)
|
| 112 |
asyncio.create_task(change_music_tone(state.user_hash, music_prompt))
|
| 113 |
state.scene = next_scene
|
|
|
|
| 94 |
"last_choice": state.choice_text,
|
| 95 |
}
|
| 96 |
)
|
| 97 |
+
change_scene = await generate_image_prompt(state.user_hash, next_scene["description"], state.choice_text)
|
| 98 |
current_image = None
|
| 99 |
if scene_id and scene_id in user_state.scenes:
|
| 100 |
current_image = user_state.scenes[scene_id].image
|
|
|
|
| 107 |
"change_scene": change_scene,
|
| 108 |
}
|
| 109 |
)
|
| 110 |
+
music_task = generate_music_prompt(state.user_hash, next_scene["description"], state.choice_text)
|
| 111 |
_, music_prompt = await asyncio.gather(image_task, music_task)
|
| 112 |
asyncio.create_task(change_music_tone(state.user_hash, music_prompt))
|
| 113 |
state.scene = next_scene
|
src/agent/music_agent.py
CHANGED
|
@@ -40,7 +40,7 @@ class MusicPrompt(BaseModel):
|
|
| 40 |
llm = create_light_llm(0.1).with_structured_output(MusicPrompt)
|
| 41 |
|
| 42 |
|
| 43 |
-
async def generate_music_prompt(user_hash: str, scene_description: str) -> str:
|
| 44 |
logger.info(f"Generating music prompt for the current scene: {scene_description}")
|
| 45 |
|
| 46 |
state = get_user_state(user_hash)
|
|
|
|
| 40 |
llm = create_light_llm(0.1).with_structured_output(MusicPrompt)
|
| 41 |
|
| 42 |
|
| 43 |
+
async def generate_music_prompt(user_hash: str, scene_description: str, last_choice = "No choice yet") -> str:
|
| 44 |
logger.info(f"Generating music prompt for the current scene: {scene_description}")
|
| 45 |
|
| 46 |
state = get_user_state(user_hash)
|