리스트의 각 항목에 대해 크루를 시작하려면 kickoff_for_each() 메서드를 사용하세요.
이 메서드는 리스트의 각 항목에 대해 크루를 실행하여 여러 항목을 효율적으로 처리할 수 있도록 합니다.아래는 리스트의 각 항목에 대해 크루를 시작하는 방법의 예시입니다:
Code
Copy
Ask AI
from crewai import Crew, Agent, Task# Create an agent with code execution enabledcoding_agent = Agent( role="Python Data Analyst", goal="Analyze data and provide insights using Python", backstory="You are an experienced data analyst with strong Python skills.", allow_code_execution=True)# Create a task that requires code executiondata_analysis_task = Task( description="Analyze the given dataset and calculate the average age of participants. Ages: {ages}", agent=coding_agent, expected_output="The average age calculated from the dataset")# Create a crew and add the taskanalysis_crew = Crew( agents=[coding_agent], tasks=[data_analysis_task], verbose=True, memory=False)datasets = [ { "ages": [25, 30, 35, 40, 45] }, { "ages": [20, 25, 30, 35, 40] }, { "ages": [30, 35, 40, 45, 50] }]# Execute the crewresult = analysis_crew.kickoff_for_each(inputs=datasets)