Hi. I鈥檓 trying to get a basic/simple/proof-of-concept example for getting smolagents to work with phoenix. I鈥檓 using smolagents 1.8 Can anyone tell what is wrong and/or point me in the right direction, and/perhaps a quickstart python script that works with a local phoenix install? Thanks
import os
from dotenv import load_dotenv
import phoenix as px
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
from smolagents import CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool, LiteLLMModel
# Load environment variables from a .env file
load_dotenv()
def main():
# 1. Start Phoenix
session = px.Client()
px.launch_app()
# 2. Instrument SmolAgents
SmolagentsInstrumentor().instrument()
# 3. Create model and agents
model = LiteLLMModel(model_id="openai/gpt-4o-mini")
search_agent = ToolCallingAgent(
tools=[DuckDuckGoSearchTool()],
model=model,
name="web_search_agent",
description="Performs web searches"
)
manager_agent = CodeAgent(
tools = [],
managed_agents=[search_agent],
model=model,
name="main_agent",
description="Orchestrates agents"
)
# 4. Run query
response = manager_agent.run("Current US GDP growth rate")
print("Response:", response)
# 5. Keep Phoenix running
print(f"\nPhoenix UI: {session.url}\n")
input("Press Enter to exit...")
if __name__ == "__main__":
main()Hey Graham A. - we can probably help you more in depth over on the Phoenix Support channel. You are missing a few steps however like setting up opentelemetry https://github.com/huggingface/smolagents/blob/main/docs/source/en/tutorials/inspect_runs.md LMK if that helps! You can also talk to RunLLM for help
To get Smolagents working with Phoenix, you need to ensure that OpenTelemetry is set up correctly. Here's a basic outline of what you need to do: 1. Install Required Packages: Make sure you have all necessary packages installed, including smolagents, phoenix, opentelemetry, and openinference-instrumentation-smolagents.2. Set Up OpenTelemetry: You need to configure OpenTelemetry to export traces to Phoenix. This involves setting up a tracer provider and span exporter.3. Instrument Smolagents: Use the SmolagentsInstrumentor to instrument your agents.Here's a quickstart example based on the provided code: ```import os
from dotenv import load_dotenv
import phoenix as px
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
from smolagents import CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool, LiteLLMModel
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter# Load environment variables from a .env file
load_dotenv()def main():
# 1. Start Phoenix
session = px.Client()
px.launch_app() # 2. Set up OpenTelemetry
tracer_provider = TracerProvider()
span_exporter = OTLPSpanExporter(endpoint="http://localhost:6006/v1/traces")
span_processor = SimpleSpanProcessor(span_exporter)
tracer_provider.add_span_processor(span_processor) # 3. Instrument SmolAgents
SmolagentsInstrumentor().instrument(tracer_provider=tracer_provider) # 4. Create model and agents
model = LiteLLMModel(model_id="openai/gpt-4o-mini")
search_agent = ToolCallingAgent(
tools=[DuckDuckGoSearchTool()],
model=model,
name="web_search_agent",
description="Performs web searches"
)
manager_agent = CodeAgent(
tools = [],
managed_agents=[search_agent],
model=model,
name="main_agent",
description="Orchestrates agents"
)
# 5. Run query
response = manager_agent.run("Current US GDP growth rate")
print("Response:", response)LBKS # 6. Keep Phoenix running
print(f"\nPhoenix UI: {session.url}\n")
input("Press Enter to exit...")LBKSif __name__ == "__main__":
main()LBKS```LBKSLBKSMake sure your Phoenix server is running and accessible at the specified endpoint. If you need more detailed guidance, feel free to ask for help in the relevant Slack channel or consult the [Smolagents documentation](https://github.com/huggingface/smolagents/blob/main/docs/source/en/tutorials/inspect_runs.md).LBKSSources:
馃挕聽Hint: Mention RunLLM in the thread for followups.
Thanks 馃檪 That got it working
