File size: 684 Bytes
b4a8f47 2448e3b 8ae4228 b4a8f47 8ae4228 2448e3b 8ae4228 b4a8f47 b72a676 b4a8f47 b72a676 b4a8f47 2448e3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from smolagents import Tool
import requests
class ImageAnalysisTool(Tool):
name = "image_analysis"
description = "Analyzes an image and extracts text."
inputs = {
"image_path": {
"type": "string",
"description": "Path to the image file"
}
}
output_type = "string"
def forward(self, image_path: str) -> str:
with open(image_path, "rb") as f:
response = requests.post(
"https://ankitaofficialdutta02--modal-image-analyzer-fastapi-app.modal.run/analyze-image/",
files={"file": f}
)
return response.json().get("text", "No text found in the image.")
|