Represents a pasted image with its base64 encoding.
| 64 | |
| 65 | @dataclass |
| 66 | class ImageData: |
| 67 | """Represents a pasted image with its base64 encoding.""" |
| 68 | |
| 69 | base64_data: str |
| 70 | format: str # "png", "jpeg", etc. |
| 71 | placeholder: str # Display text like "[image 1]" |
| 72 | |
| 73 | def to_message_content(self) -> dict: |
| 74 | """Convert to LangChain message content format. |
| 75 | |
| 76 | Returns: |
| 77 | Dict with type and image_url for multimodal messages. |
| 78 | """ |
| 79 | return { |
| 80 | "type": "image_url", |
| 81 | "image_url": {"url": f"data:image/{self.format};base64,{self.base64_data}"}, |
| 82 | } |
| 83 | |
| 84 | |
| 85 | @dataclass |
no outgoing calls