crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.92k stars 2.6k forks source link

Pydantic Error : A non-annotated attribute was detected: `is_crew_class = True` | this is not from my code #613

Closed steelliberty closed 1 week ago

steelliberty commented 3 months ago

Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/Users/jackmullen/jmautogpt/news_agency_1/main.py", line 7, in from crew import NewsSourceResearcher File "/Users/jackmullen/jmautogpt/news_agency_1/crew.py", line 12, in @CrewBase ^^^^^^^^ File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/crewai/project/crew_base.py", line 12, in CrewBase class WrappedClass(cls): File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 93, in new private_attributes = inspect_namespace( ^^^^^^^^^^^^^^^^^^ File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 406, in inspect_namespace raise PydanticUserError( pydantic.errors.PydanticUserError: A non-annotated attribute was detected: is_crew_class = True. All model fields require a type annotation; if is_crew_class is not meant to be a field, you may be able to resolve this error by annotating it as a ClassVar or updating model_config['ignored_types'].

For further information visit https://errors.pydantic.dev/2.7/u/model-field-missing-annotation

The file that caused that error below:

import os from crewai import Agent, Crew, Process, Task from crewai.project import CrewBase, agent, crew, task from crewai_tools import WebsiteSearchTool from langchain_community.tools import DuckDuckGoSearchRun# Initialize the tool search_tool = DuckDuckGoSearchRun() from langchain_groq import ChatGroq import sqlite3

@CrewBase class NewsSourceResearcher(Agent):

def __init__(self, zip=None) -> None:
    if zip == None:
        pass
    # add other models here
    self.groq_llm = ChatGroq(temperature=0, model='llama3-8b-8192')
    self.agents_config = 'config/agents.yaml'
    self.tasks_config = 'config/tasks.yaml'

@agent
def source_manager(self) -> Agent:
    return Agent(config=self.agents_config['source_manager'],
                 llm=self.groq_llm,)
@task
def source_manager_task(self) -> Task:
    return Task(
        config=self.tasks_config['source_manager_task'],
        agent=self.source_manager(),
        tools=[search_tool,WebsiteSearchTool(),sqlite3]
    )

@crew
def crew(self) -> Crew:
    return Crew(
        agents=self.agents,
        tasks=self.tasks,
        process=Process.sequential,
        verbose=2

        )

I upgraded to install crewai==0.30.0rc6 crewai-tools==0.2.3 but Poetry downgraded both versions.

joaomdmoura commented 3 months ago

Should be fixed no on v0.30.8 :D, can you double check please? šŸ™‡šŸ¼

steelliberty commented 3 months ago

I am sorry -- but it now has a new error -- I upgraded to 0.30.8 and tools 0.2.3

Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/Users/jackmullen/jmautogpt/news_agency_1/main.py", line 7, in from crew import NewsSourceResearcher File "/Users/jm/jmautogpt/news_agency_1/crew.py", line 12, in @CrewBase ^^^^^^^^ File "/Users/jm/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/crewai/project/crew_base.py", line 13, in CrewBase class WrappedClass(cls): File "/Users/jm/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 93, in new private_attributes = inspect_namespace( ^^^^^^^^^^^^^^^^^^ File "/Users/jm/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 343, in inspect_namespace all_ignored_types = ignored_types + default_ignored_types()


TypeError: can only concatenate list (not "tuple") to list
joaomdmoura commented 3 months ago

weird that I can't replicate the problem but let me try chancing it again

steelliberty commented 3 months ago

I am using poetry - and not in the case above -- but if run poetry install it will downgrade both crewai and the tools -- I am not in love with poetry - should i remove it ?

steelliberty commented 3 months ago

I am here now if you wanted to help me out -- strange thing is I have another crew setup with the same structure (config file of yamls and methods as shown in my crew.py, and I got it to work. I duplicated the structure and install all new requirements in the new environment and these issues appear, it would then have to be a result of the upgraded modules and their interactions. Another question that you could answer -- quickly -- I do not seem to be able to add tools using the Tasks yaml file
tools:

steelliberty commented 3 months ago

after figuring out that i had a value for tools in pyproject.toml that prevented crewai .. I have a new error message:

Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/Users/jackmullen/jmautogpt/news_agency_1/main.py", line 7, in from crew import NewsSourceResearcher File "/Users/jackmullen/jmautogpt/news_agency_1/crew.py", line 12, in @CrewBase ^^^^^^^^ File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/crewai/project/crew_base.py", line 13, in CrewBase class WrappedClass(cls): File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 91, in new config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jackmullen/jmautogpt/news_agency_1/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py", line 128, in for_model raise PydanticUserError('"Config" and "model_config" cannot be used together', code='config-both') pydantic.errors.PydanticUserError: "Config" and "model_config" cannot be used together

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 week ago

This issue was closed because it has been stalled for 5 days with no activity.