crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

issue with below code

Open mustangs0786 opened this issue 9 months ago • 4 comments

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

mustangs0786 avatar May 01 '24 19:05 mustangs0786

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

maxcurrent420 avatar May 04 '24 04:05 maxcurrent420

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

SumaiyaSultan2002 avatar May 06 '24 09:05 SumaiyaSultan2002

can you give a sample example expected_output to put here thanks

mustangs0786 avatar May 07 '24 17:05 mustangs0786

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

SumaiyaSultan2002 avatar May 08 '24 07:05 SumaiyaSultan2002

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] avatar Aug 17 '24 12:08 github-actions[bot]

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

github-actions[bot] avatar Aug 23 '24 12:08 github-actions[bot]