Comet은 호스팅된 Opik 플랫폼을 제공하거나, 로컬에서 플랫폼을 실행할 수도 있습니다.호스팅 버전을 사용하려면 무료 Comet 계정 만들기 후 API 키를 발급받으세요.Opik 플랫폼을 로컬에서 실행하려면, 설치 가이드에서 자세한 정보를 확인하세요.이 가이드에서는 CrewAI의 빠른 시작 예제를 사용합니다.
1
필수 패키지 설치
Copy
Ask AI
pip install crewai crewai-tools opik --upgrade
2
Opik 구성
Copy
Ask AI
import opikopik.configure(use_local=False)
3
환경 준비
먼저, LLM 제공업체의 API 키를 환경 변수로 설정합니다:
Copy
Ask AI
import osimport getpassif "OPENAI_API_KEY" not in os.environ:os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter your OpenAI API key: ")
4
CrewAI 사용하기
첫 번째 단계는 프로젝트를 만드는 것입니다. CrewAI 문서의 예제를 사용하겠습니다:
Copy
Ask AI
from crewai import Agent, Crew, Task, Processclass YourCrewName: def agent_one(self) -> Agent: return Agent( role="Data Analyst", goal="Analyze data trends in the market", backstory="An experienced data analyst with a background in economics", verbose=True, ) def agent_two(self) -> Agent: return Agent( role="Market Researcher", goal="Gather information on market dynamics", backstory="A diligent researcher with a keen eye for detail", verbose=True, ) def task_one(self) -> Task: return Task( name="Collect Data Task", description="Collect recent market data and identify trends.", expected_output="A report summarizing key trends in the market.", agent=self.agent_one(), ) def task_two(self) -> Task: return Task( name="Market Research Task", description="Research factors affecting market dynamics.", expected_output="An analysis of factors influencing the market.", agent=self.agent_two(), ) def crew(self) -> Crew: return Crew( agents=[self.agent_one(), self.agent_two()], tasks=[self.task_one(), self.task_two()], process=Process.sequential, verbose=True, )
이제 Opik의 추적기를 임포트하고 crew를 실행할 수 있습니다:
Copy
Ask AI
from opik.integrations.crewai import track_crewaitrack_crewai(project_name="crewai-integration-demo")my_crew = YourCrewName().crew()result = my_crew.kickoff()print(result)