(self, media: MediaInput)
| 10709 | return data |
| 10710 | |
| 10711 | def load_media(self, media: MediaInput) -> bytes: |
| 10712 | if media.url is not None: |
| 10713 | return self._load_media_url(media.kind, media.url) |
| 10714 | if media.kind not in {"audio", "video"} or media.data is None: |
| 10715 | raise CompletionRequestValidationError(f"{media.kind} input requires a URL") |
| 10716 | try: |
| 10717 | data = base64.b64decode(media.data, validate=False) |
| 10718 | except (ValueError, binascii.Error) as exc: |
| 10719 | raise CompletionRequestValidationError(f"input_{media.kind} data must be valid base64") from exc |
| 10720 | max_bytes = self._max_bytes_for_media(media.kind) |
| 10721 | if len(data) > max_bytes: |
| 10722 | raise CompletionRequestValidationError( |
| 10723 | f"{media.kind} exceeds model.mtmd.{media.kind}_max_bytes" |
| 10724 | ) |
| 10725 | return data |
| 10726 | |
| 10727 | def _create_loaded_media( |
| 10728 | self, |
no test coverage detected