Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
Traceback (most recent call last):
File "", line 1, in
File "D:\AIGC\idataai_py\test\crew_template\src\crew_template\main.py", line 18, in run
CrewTemplateCrew().crew().kickoff(inputs=inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AIGC\idataai_py\test\crew_template\crewenv\Lib\site-packages\crewai\project\crew_base.py", line 51, in crew
return Crew(agents=agents, tasks=tasks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AIGC\idataai_py\test\crew_template\crewenv\Lib\site-packages\pydantic\main.py", line 212, in init
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
Value error, Task '用中文基于获取的{topic}数据进行全面准确的分析并尽量从多个维度进行总结
' has a context dependency on a future task '获取que_id为1的{topic}数据
', which is not allowed. [type=value_error, input_value={'agents': [Agent(role={t...=获取{topic}数据
)]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
An error occurred while running the crew: Command '['poetry', 'run', 'run_crew']' returned non-zero exit status 1.
Description
It runs normally in version 0.63.6, but an error occurs when running in the latest version.
Steps to Reproduce
crewai run
Expected behavior
It runs normally in the latest version.
Screenshots/Code snippets
task.yaml:
assistant_task: description: > 获取que_id为1的{topic}数据 expected_output: > 获取{topic}数据 agent: assistant_agent
summary_task: description: > 用中文基于获取的{topic}数据进行全面准确的分析并尽量从多个维度进行总结 expected_output: > 不少于50个字中文总结 agent: summary_agent
################################################################
### custom_tool.py: from crewai_tools import BaseTool, tool import json import mysql.connector import pandas as pd
def get_json_by_mysql(sql): mysql_conn = mysql.connector.connect( host="xxx", database="xxx", user="xxx", password="xxx" ) cursor = mysql_conn.cursor() cursor.execute(sql) columns = [column[0] for column in cursor.description] data = [dict(zip(columns, row)) for row in cursor.fetchall()] cursor.close() mysql_conn.close() result = json.loads(json.dumps(data, indent=4, default=str, ensure_ascii=False)) return result
def get_meta_list(obj, key): result = [] for item in obj: for k, v in item.items(): if k == key: result.append(v) return result
@tool("获取数据工具") def dataframe_tool(que_id: int): """根据给定的que_id获取数据""" sql = f"select query_result from
supersonic-dev
.s2_chat_query where question_id = {que_id}" query_result = get_json_by_mysql(sql)[0]["query_result"] if len(query_result) == 0: raise Exception("query_result为空") query_result = json.loads(query_result) query_sql = query_result["querySql"] query_data = get_json_by_mysql(query_sql) query_columns = query_result["queryColumns"] col_names = get_meta_list(query_columns, "nameEn") col_notes = get_meta_list(query_columns, "name") df = pd.json_normalize(query_data, meta=col_names) df.columns = col_notes return df####################################################################
### crew.py: from crewai import Agent, Crew, Process, Task from crewai.project import CrewBase, agent, crew, task from crew_template.tools.custom_tool import dataframe_tool from langchain_openai import AzureChatOpenAI, ChatOpenAI import os import litellm
os.environ["OPENAI_API_KEY"] = "xxx" os.environ["temperature"] = '0' litellm.api_base = "xxx"
@CrewBase class CrewTemplateCrew: """CrewTemplate crew""" agents_config = 'config/agents.yaml' tasks_config = 'config/tasks.yaml'
Operating System
Windows 10
Python Version
3.11
crewAI Version
0.64.0
crewAI Tools Version
0.12.1
Virtual Environment
Venv
Evidence
Traceback (most recent call last): File "", line 1, in
File "D:\AIGC\idataai_py\test\crew_template\src\crew_template\main.py", line 18, in run
CrewTemplateCrew().crew().kickoff(inputs=inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AIGC\idataai_py\test\crew_template\crewenv\Lib\site-packages\crewai\project\crew_base.py", line 51, in crew
return Crew(agents=agents, tasks=tasks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AIGC\idataai_py\test\crew_template\crewenv\Lib\site-packages\pydantic\main.py", line 212, in init
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
Value error, Task '用中文基于获取的{topic}数据进行全面准确的分析并尽量从多个维度进行总结
' has a context dependency on a future task '获取que_id为1的{topic}数据
', which is not allowed. [type=value_error, input_value={'agents': [Agent(role={t...=获取{topic}数据
)]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
An error occurred while running the crew: Command '['poetry', 'run', 'run_crew']' returned non-zero exit status 1.
Possible Solution
None
Additional context
None