Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ telemetry = [
]
transformers = [
"accelerate",
"transformers>=4.0.0,<4.49.0",
"transformers>=4.0.0",
"smolagents[torch]",
]
all = [
Expand Down
4 changes: 0 additions & 4 deletions src/smolagents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from huggingface_hub.utils import is_torch_available
from PIL import Image

from .tools import Tool
from .utils import _is_package_available, encode_image_base64, make_image_url
Expand Down Expand Up @@ -712,7 +711,6 @@ def __call__(
stop_sequences: Optional[List[str]] = None,
grammar: Optional[str] = None,
tools_to_call_from: Optional[List[Tool]] = None,
images: Optional[List[Image.Image]] = None,
**kwargs,
) -> ChatMessage:
completion_kwargs = self._prepare_completion_kwargs(
Expand All @@ -737,14 +735,12 @@ def __call__(
completion_kwargs["max_new_tokens"] = max_new_tokens

if hasattr(self, "processor"):
images = [Image.open(image) for image in images] if images else None
prompt_tensor = self.processor.apply_chat_template(
messages,
tools=[get_tool_json_schema(tool) for tool in tools_to_call_from] if tools_to_call_from else None,
return_tensors="pt",
tokenize=True,
return_dict=True,
images=images,
add_generation_prompt=True if tools_to_call_from else False,
)
else:
Expand Down