| 1 | from pydantic import BaseModel, Field |
| 2 | from typing import List, Optional, Literal, Tuple |
| 3 | from interfaces.environment import EnvironmentInScene |
| 4 | from interfaces.character import CharacterInScene |
| 5 | |
| 6 | |
| 7 | class Scene(BaseModel): |
| 8 | idx: int = Field( |
| 9 | description="The scene index, starting from 0", |
| 10 | examples=[0, 1, 2], |
| 11 | ) |
| 12 | is_last: bool = Field( |
| 13 | description="Indicates if this is the last scene", |
| 14 | examples=[False, True], |
| 15 | ) |
| 16 | environment: EnvironmentInScene = Field( |
| 17 | description="The detailed scene setting, including location and time", |
| 18 | ) |
| 19 | characters: List[CharacterInScene] = Field( |
| 20 | description="A list of characters appearing in the scene, along with their dynamic features like clothing and accessories", |
| 21 | ) |
| 22 | script: str = Field( |
| 23 | description="The screenplay script for the scene, including character actions and dialogues. Character names in the script should be enclosed in <>, except for character names within dialogues.", |
| 24 | examples=[ |
| 25 | "<Jane> paces nervously, clutching a letter. She turns to <John>.\n<Jane>: John, we need to leave tonight.\n<John> shakes his head, stepping toward the window.\n<John>: It's too dangerous.", |
| 26 | "<Alice> sits quietly, observing the chaos around her. She whispers to <Bob>.\n<Alice>: Bob, do you think they'll find us here?\n<Bob> nods slowly, his expression grim." |
| 27 | ], |
| 28 | ) |
| 29 | |
| 30 | def __str__(self): |
| 31 | s = f"Scene {self.idx}:" |
| 32 | s += f"\nEnvironment: {str(self.environment)}" |
| 33 | s += f"\nCharacters: {', '.join([str(c) for c in self.characters])}" |
| 34 | s += f"\nScript: \n{self.script}" |
| 35 | return s |
| 36 | |
| 37 | |
| 38 | |
| 39 | # class Scene(BaseModel): |
| 40 | # index: int = Field( |
| 41 | # description="The index of the scene within the event, starting from 0" |
| 42 | # ) |
| 43 | # character_indices: List[int] = Field( |
| 44 | # description="List of indices of characters appearing in this scene, including main characters, supporting characters, and extras.", |
| 45 | # ) |
| 46 | # environment_index: int = Field( |
| 47 | # description="The index of the environment where the scene takes place." |
| 48 | # ) |
| 49 | # key_items_indices: List[int] = Field( |
| 50 | # default=[], |
| 51 | # description="List of indices of key items involved in this scene, if any.", |
| 52 | # ) |
| 53 | # script: str = Field( |
| 54 | # description="The script of the scene, including actions and dialogues" |
| 55 | # ) |
| 56 | |
| 57 | |
| 58 |