1. Installation
First install the traceAI and necessary dependencies.
pip install traceAI-smolagents smolagents
2. Set Environment Variables
Set up your environment variables to authenticate with both FutureAGI and OpenAI.
import os
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
3. Initialize Trace Provider
Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="smolagents",
)
4. Instrument your Project
Instrument your Project with SmolagentsInstrumentor . This step ensures that all interactions with the Agents are tracked and monitored.
from traceai_smolagents import SmolagentsInstrumentor
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
5. Interact with Smol Agents
Interact with you Smol Agents as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.
from smolagents import (
CodeAgent,
DuckDuckGoSearchTool,
OpenAIServerModel,
ToolCallingAgent,
)
model = OpenAIServerModel(model_id="gpt-4o")
agent = ToolCallingAgent(
tools=[DuckDuckGoSearchTool()],
model=model,
max_steps=3,
name="search",
description=(
"This is an agent that can do web search. "
"When solving a task, ask him directly first, he gives good answers. "
"Then you can double check."
),
)
manager_agent = CodeAgent(
tools=[DuckDuckGoSearchTool()],
model=model,
managed_agents=[agent],
)
manager_agent.run(
"How many seconds would it take for a leopard at full speed to run through Pont des Arts? "
"ASK YOUR MANAGED AGENT FOR LEOPARD SPEED FIRST"
)