Hello,
I have a set of Tasks defined and, when I define a task as context to another it give me error. If I remove the context it works fine.
Any hint? basically I have two research tasks that serves as input for the proposal generation task.
Here a snippet of my tasks.
class SBDTasks():
def __init__(self):
self.timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
self.proposal_status = "draft"
#self.review_scores = {}
def company_research_task(self, agent, business_name: str, business_website: str, lead_country: str, cities: str) -> Task:
"""
Create a task for researching the target company's profile, structure, and market position.
Args:
agent: Research agent to perform the task
business_name: Name of the target company
business_website: Company's website
lead_country: Primary country of operation
cities: Cities where company operates and where the project will be implemented
"""
task = Task(
description=dedent(f"""
COMPANY RESEARCH: {business_name}
Conduct comprehensive research on {business_name} to support proposal creation.
Compile findings in a structured report highlighting insights relevant for proposal creation.
"""),
expected_output=dedent("""
A comprehensive research report
"""),
agent=agent,
output_pydantic=CompanyResearch,
async_execution=True,
output_file=f'data/company_research_{self.timestamp}.json'
)
return task
def project_research_task(self, agent, business_objective: str, interest_area: str, challenges_faced: str, technical_constraints: str, proposed_options: str) -> Task:
"""
A task for researching the specific project needs and industry context.
Args:
agent: Research agent to perform the task
proposal_type: Type of proposal/project
interest_area: Primary area of interest
statement_of_work: Project scope
interests: Specific interests/requirements
"""
task = Task(
description=dedent(f"""
PROJECT RESEARCH: {business_objective}
Conduct comprehensive research to support a proposal for {business_objective},
focusing on the following areas: {', '.join(interest_area)}.
Compile findings focusing on practical applications for the proposal.
"""),
expected_output=dedent('''
{
"project_name": "Example Project",
"research_date": "2025-01-10",
"interest_areas": ["Infrastructure", "Cloud Computing"],
"solution_options": [
{
"name": "Solution A",
"features": {
"key_features": ["Feature 1", "Feature 2"],
"technical_specifications": {"spec1": "value1"}
},
"costs": {
"initial_investment": 100000,
"operational_costs": 50000,
"total_cost_3_years": 250000,
"total_cost_5_years": 400000
}
},
{
"name": "Solution B"
// Similar structure for second solution
}
],
"solution_comparison": {
"comparison_criteria": ["Cost", "Performance", "Scalability"],
"scoring_matrix": {
"Solution A": {"Cost": 8.5, "Performance": 9.0},
"Solution B": {"Cost": 7.5, "Performance": 9.5}
}
}
}
'''),
agent=agent,
output_pydantic=ProjectResearch,
async_execution=True,
output_file=f'data/project_research_{self.timestamp}.json'
)
return task
def proposal_creation(self, agent, business_name: str, lead_country: str, cities: str, proposal_type: str, iteration=0, previous_review=None) -> Task:
"""
Create or revise a business proposal based on iteration number and previous review.
Args:
iteration: Current iteration number (0 for initial, >0 for revisions)
previous_review: Previous review feedback (None for initial proposal)
"""
revision_context = ""
if iteration > 0 and previous_review:
revision_context = dedent(f"""
# Revision Context (Iteration {iteration})
This is a revision based on previous review feedback. Address the following points:
{previous_review}
Focus on:
1. Addressing all review comments
2. Strengthening identified weak areas
3. Maintaining successful elements
4. Documenting major changes made
Include a change log at the end of the proposal.
""")
task = Task(
description=dedent(f"""
{'PROPOSAL REVISION' if iteration > 0 else 'NEW PROPOSAL'} for {business_name}
{revision_context}
Create a professional business proposal for XXX's consulting services for {business_name}.
{f'REVISION ITERATION {iteration + 1}: Please address previous review feedback.' if iteration > 0 else ''}
Create this proposal focusing on {business_name}'s specific needs while maintaining Onzo's professional standards.
Each section should flow logically into the next, building a compelling case for choosing XXX, LDA.
"""
),
expected_output=dedent("""
A complete proposal document with the following clear sections
End the document with a clear marker:
---END_PROPOSAL---
"""),
agent=agent,
#async_execution=True,
context=[self.company_research_task, self.project_research_task],
#output_pydantic=Proposal,
#guardrail=validate_proposal_content,
output_file=f'data/proposal_v{iteration + 1}_{self.timestamp}.md'
)
return task