Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with below code #549

Open
mustangs0786 opened this issue May 1, 2024 · 4 comments
Open

issue with below code #549

mustangs0786 opened this issue May 1, 2024 · 4 comments

Comments

@mustangs0786
Copy link

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
Copy link

maxcurrent420 commented May 4, 2024

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
Copy link

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

@mustangs0786
Copy link
Author

can you give a sample example expected_output to put here
thanks

@SumaiyaSultan2002
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants