mjschock's picture
Enhance agent functionality in main_v2.py by adding WikipediaSearchTool and updating DuckDuckGoSearchTool and VisitWebpageTool parameters. Modify agent initialization to accommodate new tools and increase max results and output length. Update requirements.txt to include Wikipedia-API dependency. Refactor imports for better organization across agent modules.
e4c7240 unverified
raw
history blame contribute delete
949 Bytes
import io
from typing import Any, Dict
import requests
from PIL import Image
from smolagents import tool
@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)}