Arize Phoenix 통합

Arize Phoenix 통합 (Arize Phoenix Integration)

이 가이드는 OpenInference SDK를 통한 OpenTelemetry로 Arize Phoenix를 CrewAI와 통합하는 방법을 보여줘요. 이 가이드를 끝내면 CrewAI 에이전트를 트레이스하고 에이전트 동작을 디버그할 수 있어요.

출처: 문서

본문

Arize Phoenix란 무엇인가요? Arize Phoenix는 Arize AI의 오픈소스 옵저버빌리티·평가 옵션이에요. 로컬에서 실행하거나 자체 호스팅(self-host)하고 싶을 때 Phoenix를 사용하세요. 프로덕션 AI 시스템을 위한 관리형 클라우드나 엔터프라이즈 자체 호스팅 플랫폼에는 Arize AX를 사용하세요.

Get Started (시작하기)

CrewAI를 사용하고 OpenInference를 통해 OpenTelemetry로 Arize Phoenix와 통합하는 간단한 예시를 함께 살펴볼게요. 이 가이드는 Google Colab에서도 접근할 수 있어요.

Step 1: Install Dependencies

pip install openinference-instrumentation-crewai crewai crewai-tools arize-phoenix-otel

Step 2: Set Up Environment Variables

Phoenix API key와 OpenTelemetry 엔드포인트를 구성해 트레이스를 Phoenix로 보내요. 같은 설정이 collector URL을 바꿔 로컬 또는 자체 호스팅 Phoenix 엔드포인트에도 동작해요. 무료 Serper API key는 여기에서 받을 수 있어요.

import os
from getpass import getpass

# Get your Phoenix API key
PHOENIX_API_KEY = getpass("🔑 Enter your Phoenix API key: ")

# Get API keys for services
OPENAI_API_KEY = getpass("🔑 Enter your OpenAI API key: ")
SERPER_API_KEY = getpass("🔑 Enter your Serper API key: ")

# Set environment variables
os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={PHOENIX_API_KEY}"
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com" # Change this to your own endpoint if you are using a self-hosted instance
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
os.environ["SERPER_API_KEY"] = SERPER_API_KEY

Step 3: Initialize OpenTelemetry with Phoenix

트레이스 캡처를 시작하고 Phoenix로 보내기 위해 OpenInference OpenTelemetry 계측 SDK를 초기화해요.

from phoenix.otel import register

tracer_provider = register(
    project_name="crewai-tracing-demo",
    auto_instrument=True,
)

Step 4: Create a CrewAI Application

두 에이전트가 협력해 AI 발전에 관한 블로그 글을 연구·작성하는 CrewAI 애플리케이션을 만들어볼게요.

from crewai import Agent, Crew, Process, Task
from crewai_tools import SerperDevTool
from openinference.instrumentation.crewai import CrewAIInstrumentor
from phoenix.otel import register

# setup monitoring for your crew
tracer_provider = register(
    endpoint="http://localhost:6006/v1/traces")
CrewAIInstrumentor().instrument(skip_dep_check=True, tracer_provider=tracer_provider)
search_tool = SerperDevTool()

# Define your agents with roles and goals
researcher = Agent(
    role="Senior Research Analyst",
    goal="Uncover cutting-edge developments in AI and data science",
    backstory="""You work at a leading tech think tank.
    Your expertise lies in identifying emerging trends.
    You have a knack for dissecting complex data and presenting actionable insights.""",
    verbose=True,
    allow_delegation=False,
    # You can pass an optional llm attribute specifying what model you wanna use.
    # llm=ChatOpenAI(model_name="gpt-3.5", temperature=0.7),
    tools=[search_tool],
)
writer = Agent(
    role="Tech Content Strategist",
    goal="Craft compelling content on tech advancements",
    backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
    You transform complex concepts into compelling narratives.""",
    verbose=True,
    allow_delegation=True,
)

# Create tasks for your agents
task1 = Task(
    description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
    Identify key trends, breakthrough technologies, and potential industry impacts.""",
    expected_output="Full analysis report in bullet points",
    agent=researcher,
)

task2 = Task(
    description="""Using the insights provided, develop an engaging blog
    post that highlights the most significant AI advancements.
    Your post should be informative yet accessible, catering to a tech-savvy audience.
    Make it sound cool, avoid complex words so it doesn't sound like AI.""",
    expected_output="Full blog post of at least 4 paragraphs",
    agent=writer,
)

# Instantiate your crew with a sequential process
crew = Crew(
    agents=[researcher, writer], tasks=[task1, task2], verbose=1, process=Process.sequential
)

# Get your crew to work!
result = crew.kickoff()

print("######################")
print(result)

Step 5: View Traces in Phoenix

에이전트를 실행한 후 CrewAI 애플리케이션이 생성한 트레이스를 Phoenix에서 볼 수 있어요. 에이전트 상호작용과 LLM 호출의 상세한 단계를 볼 수 있고, 이는 AI 에이전트를 디버그·최적화하는 데 도움이 돼요.

Phoenix 프로젝트를 열고 project_name 파라미터에서 지정한 프로젝트로 이동하세요. 모든 에이전트 상호작용, 툴 사용, LLM 호출이 담긴 트레이스의 타임라인 뷰를 볼 수 있어요.

Version Compatibility Information (버전 호환성 정보)

  • Python 3.8+
  • CrewAI >= 0.86.0
  • Arize Phoenix >= 7.0.1
  • OpenTelemetry SDK >= 1.31.0

References (참조)

  • Phoenix Documentation — Phoenix 플랫폼 개요.
  • Arize AX — 관리형 클라우드 및 엔터프라이즈 자체 호스팅 옵저버빌리티·평가.
  • Arize agent evaluation guide — 트레이스에서 에이전트 동작을 평가하는 프로덕션 워크플로우.
  • Arize LLM evaluation guide — LLM 애플리케이션 평가 방법과 메트릭.
  • CrewAI Documentation — CrewAI 프레임워크 개요.
  • OpenTelemetry Docs — OpenTelemetry 가이드.
  • OpenInference GitHub — OpenInference SDK 소스 코드.

더 알아보기 (Learn more)