diff --git a/src/_bentoml_sdk/io_models.py b/src/_bentoml_sdk/io_models.py index 70201e59d7a..e8cac360625 100644 --- a/src/_bentoml_sdk/io_models.py +++ b/src/_bentoml_sdk/io_models.py @@ -81,7 +81,7 @@ def mime_type(cls) -> str: return "audio/*" elif format == "video": return "video/*" - return "*/*" + return "application/octet-stream" return "application/json" @classmethod @@ -178,9 +178,7 @@ def content_stream() -> t.Generator[str | bytes, None, None]: else: if is_file_type(type(obj)) and isinstance(serde, JSONSerde): if isinstance(obj, pathlib.PurePath): - media_type = ( - mimetypes.guess_type(obj)[0] or "application/octet-stream" - ) + media_type = mimetypes.guess_type(obj)[0] or cls.mime_type() should_inline = media_type.startswith("image") content_disposition_type = ( "inline" if should_inline else "attachment" @@ -310,7 +308,9 @@ def from_output(cls, func: t.Callable[..., t.Any]) -> type[IODescriptor]: def ensure_io_descriptor(output_type: type) -> type[IODescriptor]: - if inspect.isclass(output_type) and issubclass(output_type, BaseModel): + from pydantic._internal._utils import lenient_issubclass + + if inspect.isclass(output_type) and lenient_issubclass(output_type, BaseModel): if not issubclass(output_type, IODescriptor): return t.cast( t.Type[IODescriptor],