OpenAI Agents SDK를 사용하면 OpenAI의 모델로 구동되는 에이전트 애플리케이션을 구축할 수 있습니다.
LangSmith를 사용하여 OpenAI Agents SDK로 LLM 애플리케이션을 추적하는 방법을 알아보세요.
Installation
Python SDK 버전 langsmith>=0.3.15가 필요합니다.
OpenAI Agents 지원과 함께 LangSmith를 설치하세요:
pip install "langsmith[openai-agents]"
이렇게 하면 LangSmith 라이브러리와 OpenAI Agents SDK가 모두 설치됩니다.
Quick Start
OpenAIAgentsTracingProcessor 클래스를 사용하여 OpenAI Agents SDK와 LangSmith 추적을 통합할 수 있습니다.
import asyncio
from agents import Agent, Runner, set_trace_processors
from langsmith.integrations.openai_agents_sdk import OpenAIAgentsTracingProcessor
async def main():
agent = Agent(
name="Captain Obvious",
instructions="You are Captain Obvious, the world's most literal technical support agent.",
)
question = "Why is my code failing when I try to divide by zero? I keep getting this error message."
result = await Runner.run(agent, question)
print(result.final_output)
if __name__ == "__main__":
set_trace_processors([OpenAIAgentsTracingProcessor()])
asyncio.run(main())
모든 span과 세부 정보를 포함한 에이전트의 실행 흐름이 LangSmith에 기록됩니다.