Anthropic

Anthropic

AgentOps는 Anthropic의 최신 모델을 위한 일급(first class) 지원을 제공해요. Claude, Haiku, Sonnet 모델 계열을 AgentOps로 추적하는 방법을 함께 알아볼게요.

출처: 문서

본문

Anthropic AI는 Claude, Haiku, Sonnet 시리즈 모델을 포함해 AI 도구와 서비스를 제공하는 선도 기업이에요. 더 많은 정보는 Anthropic API를 살펴보세요.

비디오 가이드: AgentOps x Anthropic

단계 (Steps)

1. AgentOps SDK 설치하기 (Install the AgentOps SDK)

pip install agentops
poetry add agentops

2. Anthropic SDK 설치하기 (Install the Anthropic SDK)

참고: anthropic>=0.32.0이 현재 지원되며, Computer Use 도구에 대한 추가 지원도 포함돼요.

pip install anthropic
poetry add anthropic

3. 코드 3줄 추가하기 (Add 3 lines of code)

참고: openai, cohere, crew 등 어떤 모델을 호출하기 전에 반드시 agentops.init을 먼저 호출해야 해요.

import agentops
from anthropic import Anthropic

agentops.init(<INSERT YOUR API KEY HERE>)
client = Anthropic()
...
# End of program (e.g. main.py)
agentops.end_session("Success") # Success|Fail|Indeterminate

팁: API key를 .env 변수로 설정하면 쉽게 사용할 수 있어요.

AGENTOPS_API_KEY=<YOUR API KEY>
ANTHROPIC_API_KEY=<YOUR ANTHROPIC API KEY>

환경 변수에 대한 자세한 내용은 Advanced Configuration에서 확인할 수 있어요.

4. 에이전트 실행하기 (Run your Agent)

프로그램을 실행하고 app.agentops.ai/drilldown을 방문해서 여러분의 에이전트를 관찰해보세요! 🕵️

팁: 실행 후 AgentOps는 대시보드의 세션으로 바로 연결되는 클릭 가능한 URL을 콘솔에 출력해요.

전체 예제 (Full Examples)

from anthropic import Anthropic
import agentops

agentops.init(<INSERT YOUR API KEY HERE>)
client = Anthropic()

message = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1024,
    messages=[{
        "role": "user",
        "content": "Write a haiku about AI and humans working together"
    }]
)

print(message.content)
agentops.end_session('Success')
from anthropic import AsyncAnthropic
import agentops
import asyncio

async def main():
    agentops.init(<INSERT YOUR API KEY HERE>)
    client = AsyncAnthropic()

    message = await client.messages.create(
        model="claude-3-opus-20240229",
        max_tokens=1024,
        messages=[{
            "role": "user",
            "content": "Write a haiku about AI and humans working together"
        }]
    )

    print(message.content)
    agentops.end_session('Success')

asyncio.run(main())

더 알아보기 (Learn more)