Spaces:
Sleeping
Sleeping
File size: 513 Bytes
00ee0b8 9cb2644 00ee0b8 7dab6f9 00ee0b8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import base64
from smolagents.tools import Tool
class ReadImageTool(Tool):
name = "read_image"
description = "Reads an image file and returns its base64 string for Gemini."
inputs = {
"file_path": {
"type": "string",
"description": "The full path of the text file to read"
}
}
output_type = "string"
def forward(self, file_path: str) -> str:
with open(file_path, "rb") as img:
return base64.b64encode(img.read()).decode("utf-8") |