mjschock's picture
Add new agent functionalities by creating agents for web browsing, data analysis, and media handling in agents.py. Introduce various tools in tools.py for web searching, webpage browsing, image analysis, PDF reading, CSV parsing, and date extraction, enhancing the overall capabilities of the agent system.
55ef143 unverified
raw
history blame
2.16 kB
from smolagents import CodeAgent
from tools import (
analyze_image,
browse_webpage,
extract_dates,
find_in_page,
parse_csv,
perform_calculation,
read_pdf,
web_search,
)
def create_web_agent(model):
"""
Create a specialized agent for web browsing tasks.
Args:
model: The model to use for the agent
Returns:
Configured CodeAgent for web browsing
"""
web_agent = CodeAgent(
tools=[web_search, browse_webpage, find_in_page, extract_dates],
model=model,
name="web_agent",
description="Specialized agent for web browsing and searching. Use this agent to find information online, browse websites, and extract information from web pages.",
add_base_tools=True,
additional_authorized_imports=["requests", "bs4", "re", "json"],
)
return web_agent
def create_data_analysis_agent(model):
"""
Create a specialized agent for data analysis tasks.
Args:
model: The model to use for the agent
Returns:
Configured CodeAgent for data analysis
"""
data_agent = CodeAgent(
tools=[parse_csv, perform_calculation],
model=model,
name="data_agent",
description="Specialized agent for data analysis. Use this agent to analyze data, perform calculations, and extract insights from structured data.",
add_base_tools=True,
additional_authorized_imports=["pandas", "numpy", "math", "csv", "io"],
)
return data_agent
def create_media_agent(model):
"""
Create a specialized agent for handling media (images, PDFs).
Args:
model: The model to use for the agent
Returns:
Configured CodeAgent for media handling
"""
media_agent = CodeAgent(
tools=[analyze_image, read_pdf],
model=model,
name="media_agent",
description="Specialized agent for handling media files like images and PDFs. Use this agent to analyze images and extract text from PDF documents.",
add_base_tools=True,
additional_authorized_imports=["PIL", "io", "requests"],
)
return media_agent