Camel AI

Camel AI

AgentOps로 CAMEL 에이전트를 추적하고 분석할 수 있어요. CAMEL-AI 에이전트에 AgentOps를 추가하는 방법을 함께 알아볼게요.

출처: 문서

본문

CAMEL-AI는 최초의 대규모 언어 모델(LLM) multi-agent 프레임워크이자, 에이전트의 scaling law를 찾는 데 전념하는 오픈소스 커뮤니티예요. 포괄적인 문서는 여기에서 확인할 수 있어요.

AgentOps를 CAMEL 에이전트에 추가하기 (Adding AgentOps to CAMEL agents)

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

pip install agentops
poetry add agentops

2. 모든 의존성과 함께 CAMEL-AI 설치하기 (Install CAMEL-AI with all dependencies)

pip install "camel-ai[all]==0.2.11"
poetry add "camel-ai[all]==0.2.11"

3. 코드에 AgentOps 코드 추가하기 (Add AgentOps code to your code)

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

import agentops
agentops.init(<INSERT YOUR API KEY HERE>)

# your code here

agentops.end_session("Success") # Success|Fail|Indeterminate

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

AGENTOPS_API_KEY=<YOUR API KEY>

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

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

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

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

전체 예제 (Full Examples)

도구가 있는 단일 에이전트 예제 (Single Agent Example with Tools)

다음은 AgentOps를 사용해 도구를 가진 단일 CAMEL 에이전트를 추적하는 간단한 예시예요:

import agentops
import os
from camel.agents import ChatAgent
from camel.messages import BaseMessage
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType

# Initialize AgentOps
agentops.init(os.getenv("AGENTOPS_API_KEY"))

# Import toolkits after AgentOps init for tracking
from camel.toolkits import SearchToolkit

# Set up the agent with search tools
sys_msg = BaseMessage.make_assistant_message(
    role_name='Tools calling operator',
    content='You are a helpful assistant'
)

# Configure tools and model
tools = [*SearchToolkit().get_tools()]
model = ModelFactory.create(
    model_platform=ModelPlatformType.OPENAI,
    model_type=ModelType.GPT_4O_MINI,
)

# Create the agent
camel_agent = ChatAgent(
    system_message=sys_msg,
    model=model,
    tools=tools,
)

# Run the agent
user_msg = 'What is CAMEL-AI.org?'
response = camel_agent.step(user_msg)
print(response)

# End the session
agentops.end_session("Success")

다중 에이전트 예제 (Multi-Agent Example)

여러 에이전트 설정을 추적하는 방법은 예제 노트북을 여기에서 확인해보세요.

더 알아보기 (Learn more)