[Model] Merge SupportsMultiModalWithRawInput with SupportsMultiModal (#23749)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-08-27 10:01:50 -07:00
committed by GitHub
parent 4f35be10a9
commit 52883ed084
5 changed files with 30 additions and 50 deletions
+11 -34
View File
@@ -52,6 +52,12 @@ class SupportsMultiModal(Protocol):
MRO of your model class.
"""
supports_multimodal_raw_input_only: ClassVar[bool] = False
"""
A flag that indicates this model supports multi-modal inputs and processes
them in their raw form and not embeddings.
"""
supports_encoder_tp_data: ClassVar[bool] = False
"""
A flag that indicates whether this model supports
@@ -143,45 +149,16 @@ def supports_multimodal(
return getattr(model, "supports_multimodal", False)
def supports_multimodal_raw_input_only(
model: Union[type[object], object]) -> bool:
return getattr(model, "supports_multimodal_raw_input_only", False)
def supports_multimodal_encoder_tp_data(
model: Union[type[object], object]) -> bool:
return getattr(model, "supports_encoder_tp_data", False)
@runtime_checkable
class SupportsMultiModalWithRawInput(SupportsMultiModal, Protocol):
"""The interface required for all multi-modal models."""
supports_multimodal_raw_input: ClassVar[Literal[True]] = True
"""
A flag that indicates this model supports multi-modal inputs and processes
them in their raw form and not embeddings.
Note:
There is no need to redefine this flag if this class is in the
MRO of your model class.
"""
@overload
def supports_multimodal_raw_input(
model: object) -> TypeIs[SupportsMultiModalWithRawInput]:
...
@overload
def supports_multimodal_raw_input(
model: type[object]) -> TypeIs[type[SupportsMultiModalWithRawInput]]:
...
def supports_multimodal_raw_input(
model: Union[type[object], object]
) -> Union[TypeIs[type[SupportsMultiModalWithRawInput]],
TypeIs[SupportsMultiModalWithRawInput]]:
return getattr(model, "supports_multimodal_raw_input", False)
@runtime_checkable
class SupportsScoreTemplate(Protocol):
"""The interface required for all models that support score template."""