crewAI
crewAI copied to clipboard
Hierarchical process error: Tasks cannot be flagged with async_execution.
I am trying to create an app using CrewAI and it returns the error below. can anyone help out on what could be the issue?
This is Task file
# tasks.py
from crewai import Task
from crewai_apps.my_agents.ResearchAgent import data_analysis_agent, prediction_agent
from crewai_tools import DirectoryReadTool, FileReadTool
crypto_data_tool = DirectoryReadTool(directory='./data/COMPUSDT.csv')
file_tool = FileReadTool()
data_analysis_task = Task(
description='Analyze cryptocurrency data to identify trends and patterns',
expected_output='A detailed report of trends and patterns in the data',
agent=data_analysis_agent,
tools=[crypto_data_tool, file_tool],
async_execution=True,
callback=lambda output: print(f"Data Analysis Task completed!\nDescription: {output.description}\nOutput: {output.raw_output}")
)
prediction_task = Task(
description='Predict future cryptocurrency prices based on analyzed data',
expected_output='A report with predicted prices for the next month',
agent=prediction_agent,
tools=[file_tool],
async_execution=True,
callback=lambda output: print(f"Prediction Task completed!\nDescription: {output.description}\nOutput: {output.raw_output}")
)
This is the Agent file
# agents.py
import os
from crewai import Agent
from crewai_tools import SerperDevTool, DirectoryReadTool, FileReadTool
os.environ["OPENAI_API_KEY"] = "NA"
crypto_data_tool = DirectoryReadTool(directory='./data/COMPUSDT.csv')
file_tool = FileReadTool()
search_tool = SerperDevTool()
data_analysis_agent = Agent(
role='Data Analyst',
goal='Analyze cryptocurrency data to identify trends and patterns',
backstory='A data analyst experienced in financial markets and cryptocurrency.',
tools=[crypto_data_tool, file_tool],
verbose=True
)
prediction_agent = Agent(
role='Predictor',
goal='Predict future cryptocurrency prices based on analyzed data',
backstory='A machine learning expert with a focus on predictive modeling.',
tools=[file_tool],
verbose=True
)
# crew.py
import os
from crewai import Crew, Process
from dotenv import load_dotenv
from .my_agents.ResearchAgent import data_analysis_agent, prediction_agent
from .my_tasks.ResearchTasks import data_analysis_task, prediction_task
from langchain_community.chat_models.ollama import ChatOllama
from langchain_community.llms.ollama import Ollama
load_dotenv()
# memory_system = MemorySystem(
# short_term=True,
# long_term=True,
# entity=True,
# contextual=True,
# embedder={"provider": "openai", "config": {"model": 'text-embedding-3-small'}}
# )
llm = Ollama(
model=os.environ['OPENAI_MODEL_NAME'],
base_url=os.environ['OPENAI_API_BASE']
)
crew = Crew(
agents=[data_analysis_agent, prediction_agent],
tasks=[data_analysis_task, prediction_task],
process=Process.hierarchical,
manager_llm=ChatOllama(model="llama3.1"),
memory_system=True,
verbose=True,
cache=True,
full_output=True,
output_log_file='crew_output.log',
llm=llm
)
This is the error
Traceback (most recent call last):
File "/Users/christdoes/Documents/projects/AILLM/CrewAI/projects/crewai-apps/main.py", line 2, in <module>
from crewai_apps.ResearchCrew import crew
File "/Users/christdoes/Documents/projects/AILLM/CrewAI/projects/crewai-apps/crewai_apps/ResearchCrew.py", line 27, in <module>
crew = Crew(
^^^^^
File "/Users/christdoes/anaconda3/lib/python3.12/site-packages/pydantic/main.py", line 193, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
I'll really appreciate if anyonr can help look into it.