Spaces:
Build error
Build error
File size: 971 Bytes
837e221 e4c7240 837e221 e4c7240 837e221 e4c7240 837e221 e4c7240 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import importlib
import yaml
from smolagents import CodeAgent
from tools import analyze_image, read_pdf
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
"""
# Load default prompts
prompt_templates = yaml.safe_load(
importlib.resources.files("smolagents.prompts")
.joinpath("code_agent.yaml")
.read_text()
)
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"],
prompt_templates=prompt_templates,
)
return media_agent
|