import asyncio
import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from phoenix.otel import register
# 设置 Arize Phoenix 的环境变量
os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={os.getenv('ARIZE_PHOENIX_API_KEY')}"
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com"
# 配置 Phoenix Tracer
tracer_provider = register(
project_name="agno-stock-price-agent", # 默认为 'default'
auto_instrument=True, # 自动使用已安装的 OpenInference 插桩
)
# 创建并配置代理
agent = Agent(
name="Stock Price Agent",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[YFinanceTools()],
instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
debug_mode=True,
)
# 使用代理
agent.print_response("What is the current price of Tesla?")