에이전트에 reasoning을 활성화하려면 에이전트를 생성할 때 reasoning=True로 설정하면 됩니다.
Copy
Ask AI
from crewai import Agentagent = Agent( role="Data Analyst", goal="Analyze complex datasets and provide insights", backstory="You are an experienced data analyst with expertise in finding patterns in complex data.", reasoning=True, # Enable reasoning max_reasoning_attempts=3 # Optional: Set a maximum number of reasoning attempts)
from crewai import Agent, Task, Crew# Create an agent with reasoning enabledanalyst = Agent( role="Data Analyst", goal="Analyze data and provide insights", backstory="You are an expert data analyst.", reasoning=True, max_reasoning_attempts=3 # Optional: Set a limit on reasoning attempts)# Create a taskanalysis_task = Task( description="Analyze the provided sales data and identify key trends.", expected_output="A report highlighting the top 3 sales trends.", agent=analyst)# Create a crew and run the taskcrew = Crew(agents=[analyst], tasks=[analysis_task])result = crew.kickoff()print(result)
reasoning 프로세스는 견고하게 설계되어 있으며, 오류 처리가 내장되어 있습니다. reasoning 중에 오류가 발생하면, 에이전트는 reasoning 계획 없이 작업을 계속 실행합니다. 이는 reasoning 프로세스가 실패하더라도 작업이 계속 실행될 수 있도록 보장합니다.코드에서 발생할 수 있는 오류를 처리하는 방법은 다음과 같습니다:
Copy
Ask AI
from crewai import Agent, Taskimport logging# reasoning 오류를 캡처하기 위해 로깅을 설정합니다logging.basicConfig(level=logging.INFO)# reasoning이 활성화된 에이전트를 생성합니다agent = Agent( role="Data Analyst", goal="Analyze data and provide insights", reasoning=True, max_reasoning_attempts=3)# 작업을 생성합니다task = Task( description="Analyze the provided sales data and identify key trends.", expected_output="A report highlighting the top 3 sales trends.", agent=agent)# 작업 실행# reasoning 중 오류가 발생해도 로그에 기록되며 실행은 계속됩니다result = agent.execute_task(task)
Task: Analyze the provided sales data and identify key trends.Reasoning Plan:I'll analyze the sales data to identify the top 3 trends.1. Understanding of the task: I need to analyze sales data to identify key trends that would be valuable for business decision-making.2. Key steps I'll take: - First, I'll examine the data structure to understand what fields are available - Then I'll perform exploratory data analysis to identify patterns - Next, I'll analyze sales by time periods to identify temporal trends - I'll also analyze sales by product categories and customer segments - Finally, I'll identify the top 3 most significant trends3. Approach to challenges: - If the data has missing values, I'll decide whether to fill or filter them - If the data has outliers, I'll investigate whether they're valid data points or errors - If trends aren't immediately obvious, I'll apply statistical methods to uncover patterns4. Use of available tools: - I'll use data analysis tools to explore and visualize the data - I'll use statistical tools to identify significant patterns - I'll use knowledge retrieval to access relevant information about sales analysis5. Expected outcome: A concise report highlighting the top 3 sales trends with supporting evidence from the data.READY: I am ready to execute the task.
이 reasoning 계획은 agent가 작업에 접근하는 방식을 체계적으로 구성하고, 발생할 수 있는 잠재적 문제를 고려하며, 기대되는 결과를 제공하도록 돕습니다.