Hello
I have a pydantic class which I want to use as the output of a task via json
models.py which is in models folder that contains empty init.py file
from pydantic import BaseModel
class PopularCategoryResponse(BaseModel):
a_list: list[str]
In my Task…
output_format: json
output_json: PopularCategoryResponse
When I run the crew I get the error
File “MYPATH.venv\Lib\site-packages\crewai\project\crew_base.py”, line 202, in _map_task_variables
self.tasks_config[task_name][“output_json”] = output_json_functions[
KeyError: ‘PopularCategoryResponse’
I am loading my info from yaml in the main.py file
def __init__(self):
# Construct the absolute path to the YAML files
base_path = os.path.dirname(__file__)
agents_path = os.path.join(base_path, 'config', 'agents.yaml')
tasks_path = os.path.join(base_path, 'config', 'tasks.yaml')
# Load the configuration from YAML files
with open(agents_path, 'r') as file:
self.agents_config = yaml.safe_load(file)
with open(tasks_path, 'r') as file:
self.tasks_config = yaml.safe_load(file)
This is getting frustrating so any rapid help would be appreciated!