| 10 | |
| 11 | |
| 12 | async def build_prompt_messages( |
| 13 | stack: Stack, |
| 14 | input_mode: InputMode, |
| 15 | generation_type: str, |
| 16 | prompt: UserTurnInput, |
| 17 | history: list[PromptHistoryMessage], |
| 18 | file_state: dict[str, str] | None = None, |
| 19 | image_generation_enabled: bool = True, |
| 20 | design_system: str | None = None, |
| 21 | ) -> Prompt: |
| 22 | plan = derive_prompt_construction_plan( |
| 23 | stack=stack, |
| 24 | input_mode=input_mode, |
| 25 | generation_type=generation_type, |
| 26 | history=history, |
| 27 | file_state=file_state, |
| 28 | ) |
| 29 | |
| 30 | strategy = plan["construction_strategy"] |
| 31 | if strategy == "update_from_history": |
| 32 | return build_update_prompt_from_history( |
| 33 | stack=stack, |
| 34 | history=history, |
| 35 | image_generation_enabled=image_generation_enabled, |
| 36 | design_system=design_system, |
| 37 | ) |
| 38 | if strategy == "update_from_file_snapshot": |
| 39 | assert file_state is not None |
| 40 | return build_update_prompt_from_file_snapshot( |
| 41 | stack=stack, |
| 42 | prompt=prompt, |
| 43 | file_state=file_state, |
| 44 | image_generation_enabled=image_generation_enabled, |
| 45 | design_system=design_system, |
| 46 | ) |
| 47 | return build_create_prompt_from_input( |
| 48 | input_mode, |
| 49 | stack, |
| 50 | prompt, |
| 51 | image_generation_enabled, |
| 52 | design_system, |
| 53 | ) |