(cls, data: Dict[str, Any])
| 34 | |
| 35 | @classmethod |
| 36 | def from_dict(cls, data: Dict[str, Any]) -> "AttachmentRecord": |
| 37 | ref_data = data.get("ref") or {} |
| 38 | raw_kind = data.get("kind", MessageBlockType.FILE.value) |
| 39 | try: |
| 40 | kind = MessageBlockType(raw_kind) |
| 41 | except ValueError: |
| 42 | kind = MessageBlockType.FILE |
| 43 | return cls( |
| 44 | ref=AttachmentRef.from_dict(ref_data), |
| 45 | kind=kind, |
| 46 | description=data.get("description"), |
| 47 | extra=data.get("extra") or {}, |
| 48 | ) |
| 49 | |
| 50 | def as_message_block(self) -> MessageBlock: |
| 51 | """Convert to a MessageBlock referencing this attachment.""" |
no test coverage detected