| 1 | from pydantic import BaseModel, Field |
| 2 | from typing import List, Optional, Union, Dict |
| 3 | |
| 4 | |
| 5 | |
| 6 | class Event(BaseModel): |
| 7 | index: int = Field( |
| 8 | description="The index of the event, starting from 0", |
| 9 | ) |
| 10 | |
| 11 | is_last: bool = Field( |
| 12 | description="Indicates if this is the last event in the sequence" |
| 13 | ) |
| 14 | |
| 15 | description: str = Field( |
| 16 | description="A concise description of the event, capturing its essence in one sentence", |
| 17 | examples=[ |
| 18 | "A thief who stole a gem from a museum was caught after a rooftop chase with guards, and the gem was recovered.", |
| 19 | ] |
| 20 | ) |
| 21 | |
| 22 | process_chain: List[str] = Field( |
| 23 | description="A list of steps or actions that make up the event's process chain, which constitutes a complete causal chain.", |
| 24 | examples=[ |
| 25 | [ |
| 26 | "A thief steals a gem from a museum, triggering the alarm. Guards notice and begin the chase.", |
| 27 | "The thief rushes out the museum's back door and dashes through narrow alleys, with guards closely pursuing and calling for backup.", |
| 28 | "The thief climbs a fire escape to the rooftops; the guards follow using low platforms on adjacent buildings.", |
| 29 | "The thief leaps across a 1.5-meter gap between two buildings. The guards hesitate but take the risky jump, nearly losing their footing.", |
| 30 | "The thief knocks over stacked wooden planks to create an obstacle. The guards dodge but lose speed.", |
| 31 | "The thief attempts to slide down a rope to the opposite rooftop, but a guard lunges and grabs their ankle. Both tumble and grapple.", |
| 32 | "Backup arrives, subduing the thief and recovering the gem.", |
| 33 | ], |
| 34 | ] |
| 35 | ) |
| 36 | |
| 37 | def __str__(self): |
| 38 | s = f"<Event {self.index}>" |
| 39 | s += f"\nDescription: {self.description}" |
| 40 | s += f"\nProcess Chain:" |
| 41 | for process in self.process_chain: |
| 42 | s += f"\n- {process}" |
| 43 | return s |