Spaces:
Build error
Build error
Refactor agent structure by modularizing agent implementations into separate directories for web, data analysis, and media agents. Remove legacy code from agents.py, prompts.py, and tools.py, enhancing maintainability. Update main_v2.py to reflect new import paths and agent initialization. Add new tools for enhanced functionality, including web searching and data extraction. Update requirements.txt to include necessary dependencies for new tools.
837e221
unverified
import io | |
from typing import Dict, Any | |
import requests | |
from PIL import Image | |
from smolagents import tool | |
def analyze_image(image_url: str) -> Dict[str, Any]: | |
""" | |
Analyze an image and extract information from it. | |
Args: | |
image_url: URL of the image to analyze | |
Returns: | |
Dictionary containing information about the image | |
""" | |
try: | |
# Download the image | |
response = requests.get(image_url) | |
response.raise_for_status() | |
# Open the image | |
img = Image.open(io.BytesIO(response.content)) | |
# Extract basic image information | |
width, height = img.size | |
format_type = img.format | |
mode = img.mode | |
return { | |
"width": width, | |
"height": height, | |
"format": format_type, | |
"mode": mode, | |
"aspect_ratio": width / height, | |
} | |
except Exception as e: | |
return {"error": str(e)} |