(image_url: str)
| 3657 | |
| 3658 | @staticmethod |
| 3659 | def _load_image(image_url: str) -> bytes: |
| 3660 | if image_url.startswith("data:"): |
| 3661 | import base64 |
| 3662 | |
| 3663 | image_bytes = base64.b64decode(image_url.split(",")[1]) |
| 3664 | return image_bytes |
| 3665 | else: |
| 3666 | import urllib.request |
| 3667 | |
| 3668 | with urllib.request.urlopen(image_url) as f: |
| 3669 | image_bytes = f.read() |
| 3670 | return image_bytes |
| 3671 | |
| 3672 | @staticmethod |
| 3673 | def get_image_urls(messages: List[llama_types.ChatCompletionRequestMessage]): |