| 191 | |
| 192 | |
| 193 | class SystemMessage(Message): |
| 194 | role: Literal['system'] = Field(default='system', description="The role of the messages author, in this case `system`.") # type: ignore |
| 195 | content: Union[str, List[Union[ |
| 196 | ContentPartText, |
| 197 | ContentPartImage, |
| 198 | ContentPartAudio, |
| 199 | ContentPartVideo, |
| 200 | ContentPartPdf, |
| 201 | ]]] = Field(description="The contents of the system message.") |
| 202 | name: Optional[str] = Field(default=None, description="An optional name for the participant. Provides the model information to differentiate between participants of the same role.") # type: ignore |
| 203 | |
| 204 | @property |
| 205 | def text(self) -> str: |
| 206 | """ |
| 207 | Automatically parse the text inside content, whether it's a string or a list of content parts. |
| 208 | """ |
| 209 | if isinstance(self.content, str): |
| 210 | return self.content |
| 211 | elif isinstance(self.content, list): |
| 212 | return '\n'.join([str(part) for part in self.content]) |
| 213 | else: |
| 214 | return '' |
| 215 | |
| 216 | def __str__(self) -> str: |
| 217 | return f'SystemMessage(content={self.text})' |
| 218 | |
| 219 | def __repr__(self) -> str: |
| 220 | return f'SystemMessage(content={repr(self.text)})' |
| 221 | |
| 222 | |
| 223 | class AssistantMessage(Message): |
no outgoing calls