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

Minor Issue in Starter_Template #186

Open
pravincoder opened this issue Oct 29, 2024 · 0 comments · May be fixed by #187
Open

Minor Issue in Starter_Template #186

pravincoder opened this issue Oct 29, 2024 · 0 comments · May be fixed by #187

Comments

@pravincoder
Copy link

pravincoder commented Oct 29, 2024

IMPORTANT ENV PACKAGE VERSIONS :-
Pydantic Version :- 2.9.2,
Crew Ai Version :- 0.76.2,
Python Version :- 3.10.15

Error : - Traceback (most recent call last): File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 59, in <module> result = custom_crew.run() File "/Users/pravincoder/Developer/Email Advertiser/main.py", line 30, in run custom_task_1 = tasks.task_1_name( File "/Users/pravincoder/Developer/Email Advertiser/tasks.py", line 13, in task_1_name return Task( File "/opt/homebrew/Caskroom/miniconda/base/envs/email-crew/lib/python3.10/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 Task expected_output Field required [type=missing, input_value={'description': "\nResear...agent 1 backstory here)}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing

Reason :- Task object requires an expected_output field, which you haven't provided. The Task model in pydantic expects specific fields to be filled based on how the Task class is defined.

Solution :- Add the expected_output field in your Task creation.
According Actual Solution:-

from crewai import Task
from textwrap import dedent


# This is an example of how to define custom tasks.
# You can define as many tasks as you want.
# You can also define custom agents in agents.py
class CustomTasks:
    def __tip_section(self):
        return "If you do your BEST WORK, I'll give you a $10,000 commission!"

    def task_1_name(self, agent, var1, var2):
        return Task(
            description=dedent(
                f"""
            Do something as part of task 1
            
            {self.__tip_section()}
    
            Make sure to use the most recent data as possible.
    
            Use this variable: {var1}
            And also this variable: {var2}
        """
            ),
        expected_output="Expected Output of this Agent(task_1_name) in simple words",
            agent=agent,
        )

    def task_2_name(self, agent):
        return Task(
            description=dedent(
                f"""
            Take the input from task 1 and do something with it.
                                       
            {self.__tip_section()}

            Make sure to do something else.
        """
            ),
        expected_output="Expected Output of this Agent(task_2_name) in simple words",
            agent=agent,
        )

I would like to create a PR on the following issue and Update few things like structure of passing Agent and Task using yaml file.

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

Successfully merging a pull request may close this issue.

1 participant