Skip to content

Commit

Permalink
Avoid using torch's Tensor or PIL's Image in chat template utils if n…
Browse files Browse the repository at this point in the history
…ot available (huggingface#34165)

* fix(utils): Avoid using torch Tensor or PIL Image if not available

* Trigger CI

---------

Co-authored-by: Matt <[email protected]>
  • Loading branch information
RezaRahemtola and Rocketknight1 authored Oct 16, 2024
1 parent bd5dc10 commit 3a10c61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/transformers/utils/chat_template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})


Expand Down

0 comments on commit 3a10c61

Please sign in to comment.