from crewai import Crew, Process, Agent, Task, TaskOutput, CrewOutput
# 에이전트 정의
researcher = Agent(
role='Researcher',
goal='기초 연구 수행',
backstory='통찰력을 발굴하는 데 열정을 가진 경험 많은 연구원'
)
analyst = Agent(
role='Data Analyst',
goal='연구 결과 분석',
backstory='패턴을 발견하는 데 능숙한 꼼꼼한 분석가'
)
writer = Agent(
role='Writer',
goal='최종 보고서 작성',
backstory='매력적인 이야기를 만드는 데 재능 있는 숙련된 작가'
)
# 작업 정의
research_task = Task(
description='관련 데이터 수집...',
agent=researcher,
expected_output='원시 데이터'
)
analysis_task = Task(
description='데이터 분석...',
agent=analyst,
expected_output='데이터 통찰'
)
writing_task = Task(
description='보고서 작성...',
agent=writer,
expected_output='최종 보고서'
)
# 순차적 프로세스로 크루 구성
report_crew = Crew(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, writing_task],
process=Process.sequential
)
# 크루 실행
result = report_crew.kickoff()
# 타입 안전한 출력 접근
task_output: TaskOutput = result.tasks[0].output
crew_output: CrewOutput = result.output