Applied to reporting_task output
class Stage2OutputModel(BaseModel):
summary: Optional[str] = Field("", description="A describe the reports structure")
highlights: Optional[List[str]] = Field([], description="each of the expanded bullet list sections")
further_work: Optional[str] = Field("", description="A summary of any further work identified")
geo_targeting: Optional[List[str]] = Field([], description="Highlight the best geographic areas to target")
keywords: Optional[List[str]] = Field([], description="A list of suggested reading to gain a deeper understanding of keywords")
cohorts: Optional[List[str]] = Field([], description="A summary of typical interest cohorts")
def __init__(self):
super().__init__()
def get_field_info_json(self) -> str:
field_info = "\n"
for field_name, field_instance in self.model_fields.items():
field_info += field_name + ", described as: " + field_instance.description + "\n"
return field_info
Note the different field_names & descriptions that ‘craft’ the output format.
Apply the same changes that we made to the research_task:
def reporting_task(self) -> Task:
model_info = Stage2OutputModel().get_field_info_json()
return Task(
# config=self.tasks_config['reporting_task'],
description="""
Review the summary you got and expand each bullet-point into a full section for a report.
Make sure the report is detailed and contains any and all relevant information.
Mention any further research todo and an overview of geographic hot-spots.
Provide a short description of any keywords given.
Show any mention of cohorts in the report.
""",
expected_output=f""" Your response must have these exact field names with values as described, : {model_info}""",
agent=self.reporting_analyst(),
output_file='report.md'
)
Mention our new model fields in the description.
Note the exact same expected_output template
now run the crew again
Try changing the initial input topic (main.py)
Output formats appear to be stable ![]()
My thoughts about Stability
Given that we introduce the model structure in the ‘expected_output’ I’m assuming that a cognitive process is made aware of the model/schema at the point where it considers its response/output. If so, then at this point the context is recent/fresh within the cognitive consideration, but more importantly, more recent than any data/info it has collected during Task execution.
A metaphor to explain:
In which of these situations are you more likely to store the information in the correct format:
- I want you to store your response in ‘this format’': Go and do your research, collect your information on this subject and return your result.
- Go and do your research, collect your information on this subject and return your result in ‘this format’
I hope we all agree that situation 2 is the most likely to get the correct format of response because in terms of ‘context’ format requirements are the most recent/last consideration.
More Thoughts
If we can have more control over Task output we would have a greater reliability of ‘inputs’ to other Task’s because the output format of the previous Task would be more recent within the next Task input context, consider it as a ‘loose’ inter Task connector/interface.
Maybe not!, Maybe so! ![]()
As usual, all comment welcome.