joaomdmoura / 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
16.83k stars 2.27k forks source link

issue with below code #549

Open mustangs0786 opened 2 months ago

mustangs0786 commented 2 months ago

from crewai import Agent, Task, Crew

from langchain_openai import ChatOpenAI

import os

os.environ["OPENAI_API_KEY"] = "NA"

llm = ChatOpenAI(

model = "crewai-llama2",

base_url = "http://localhost:11434/v1")

general_agent = Agent(role = "Math Professor",

                  goal = """Provide the solution to the students that are asking mathematical questions and give them the answer.""",

                  backstory = """You are an excellent math professor that likes to solve math questions in a way that everyone can understand your solution""",

                  allow_delegation = False,

                  verbose = True,

                  llm = llm)

task = Task (description="""what is 3 + 5""",

         agent = general_agent)

crew = Crew(

        agents=[general_agent],

        tasks=[task],

        verbose=2

    )

result = crew.kickoff()

print(result)

################################### error ValidationError Traceback (most recent call last) Cell In[26], line 31 11 llm = ChatOpenAI( 12 13 model = "llama2", 14 15 base_url = "http://localhost:11434/v1") 19 general_agent = Agent(role = "Math Professor", 20 21 goal = """Provide the solution to the students that are asking mathematical questions and give them the answer.""", (...) 28 29 llm = llm) ---> 31 task = Task (description="""what is 3 + 5""", 32 33 agent = general_agent) 37 crew = Crew( 38 39 agents=[general_agent], (...) 44 45 ) 49 result = crew.kickoff()

File /opt/homebrew/lib/python3.12/site-packages/crewai/task.py:100, in Task.init(pydantic_self, **data) 98 def init(pydantic_self, data): 99 config = data.pop("config", {}) --> 100 super().init(config, **data)

File /opt/homebrew/lib/python3.12/site-packages/pydantic/main.py:176, in BaseModel.init(self, **data) 174 # __tracebackhide__ tells pytest and some other tools to omit this function from tracebacks 175 tracebackhide = True --> 176 self.__pydantic_validator__.validate_python(data, self_instance=self)

ValidationError: 1 validation error for Task expected_output Field required [type=missing, input_value={'description': 'what is ...derstand your solution)}, input_type=dict] For further information visit https://errors.pydantic.dev/2.7/v/missing

maxcurrent420 commented 2 months ago

I have this error also- just upgraded CrewAI (on Linux) and got this validation error (was working before)

Starts with this warning also: module_import.py:87: LangChainDeprecationWarning: Importing GuardrailsOutputParser from langchain.output_parsers is deprecated. Please replace the import with the following: from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser warnings.warn(

And then the error: main.py", line 175, in __init__ self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for Task expected_output Field required [type=missing, input_value={'description': 'You will...o produce perfect code)}, input_type=dict] For further information visit https://errors.pydantic.dev/2.7/v/missing

SumaiyaSultan2002 commented 1 month ago

you didnt add the expected output in the code task = Task (description="""what is 3 + 5""", agent = general_agent, expected_output=' ')

mustangs0786 commented 1 month ago

can you give a sample example expected_output to put here thanks

SumaiyaSultan2002 commented 1 month ago

insights_task = Task( description='Identify top 10 key insights from the data in points format. ', agent=insight_researcher, expected_output='insights from the dataset', )