diff --git a/src/transformers/utils/chat_template_utils.py b/src/transformers/utils/chat_template_utils.py index 74912ce3014..c64a2c4dcb3 100644 --- a/src/transformers/utils/chat_template_utils.py +++ b/src/transformers/utils/chat_template_utils.py @@ -76,10 +76,12 @@ def _get_json_schema_type(param_type: str) -> Dict[str, str]: float: {"type": "number"}, str: {"type": "string"}, bool: {"type": "boolean"}, - Image: {"type": "image"}, - Tensor: {"type": "audio"}, Any: {}, } + if is_vision_available(): + type_mapping[Image] = {"type": "image"} + if is_torch_available(): + type_mapping[Tensor] = {"type": "audio"} return type_mapping.get(param_type, {"type": "object"})