Supported block types for multimodal message content.
| 17 | |
| 18 | |
| 19 | class MessageBlockType(str, Enum): |
| 20 | """Supported block types for multimodal message content.""" |
| 21 | |
| 22 | TEXT = "text" |
| 23 | IMAGE = "image" |
| 24 | AUDIO = "audio" |
| 25 | VIDEO = "video" |
| 26 | FILE = "file" |
| 27 | DATA = "data" |
| 28 | |
| 29 | @classmethod |
| 30 | def from_mime_type(cls, mime_type: str) -> "MessageBlockType": |
| 31 | """Guess block type from MIME type.""" |
| 32 | if not mime_type: |
| 33 | return MessageBlockType.FILE |
| 34 | if mime_type.startswith("image/"): |
| 35 | return MessageBlockType.IMAGE |
| 36 | if mime_type.startswith("audio/"): |
| 37 | return MessageBlockType.AUDIO |
| 38 | if mime_type.startswith("video/"): |
| 39 | return MessageBlockType.VIDEO |
| 40 | return MessageBlockType.FILE |
| 41 | |
| 42 | |
| 43 | @dataclass |