from smolagents import AgentImage, Tool class ImageResizeTool(Tool): name = "image_resize" description = """ Resize the image to a smaller size. The image is a PIL image. The output is the resized image. """ inputs = { "image": { "type": "image", "description": "The image to resize.", }, "width": { "type": "number", "description": "The width to resize the image to.", }, "height": { "type": "number", "description": "The height to resize the image to.", }, } output_type = "image" def __init__(self): super().__init__() def forward(self, image: AgentImage, width: int, height: int): return image.resize((width, height))