PreCET/tasks.py

117 lines
5.2 KiB
Python

from crewai import Task
from textwrap import dedent
"""
Creating Tasks Cheat Sheet:
- Begin with the end in mind. Identify the specific outcome your tasks are aiming to achieve.
- Break down the outcome into actionable tasks, assigning each task to the appropriate agent.
- Ensure tasks are descriptive, providing clear instructions and expected deliverables.
Goal:
- Develop a detailed itinerary, including city selection, attractions, and practical travel advice.
Key Steps for Task Creation:
1. Identify the Desired Outcome: Define what success looks like for your project.
- A detailed 7 day travel itenerary.
2. Task Breakdown: Divide the goal into smaller, manageable tasks that agents can execute.
- Itenerary Planning: develop a detailed plan for each day of the trip.
- City Selection: Analayze and pick the best cities to visit.
- Local Tour Guide: Find a local expert to provide insights and recommendations.
3. Assign Tasks to Agents: Match tasks with agents based on their roles and expertise.
4. Task Description Template:
- Use this template as a guide to define each task in your CrewAI application.
- This template helps ensure that each task is clearly defined, actionable, and aligned with the specific goals of your project.
Template:
---------
def [task_name](self, agent, [parameters]):
return Task(description=dedent(f'''
**Task**: [Provide a concise name or summary of the task.]
**Description**: [Detailed description of what the agent is expected to do, including actionable steps and expected outcomes. This should be clear and direct, outlining the specific actions required to complete the task.]
**Parameters**:
- [Parameter 1]: [Description]
- [Parameter 2]: [Description]
... [Add more parameters as needed.]
**Note**: [Optional section for incentives or encouragement for high-quality work. This can include tips, additional context, or motivations to encourage agents to deliver their best work.]
'''),
expected_output=[Brief explanation of expected output],
agent=agent)
"""
class TalkingTasks():
def __init__(self, job_id):
self.job_id = job_id
def __tip_section(self):
return "You work on commission, so securing the sale is your number one priority."
def research_topics(self, agent, customer):
return Task(
description=dedent(
f"""
**Task**: Develop a list of topics for small talk
**Description**: Tailor the information given by the local guide and sports analyst to
the interests of the contact. Your topics MUST be focused on the current year (2024)
and relevant. The generated topics should be supplemented by
a large amount of description to provide our agents with the means to converse with
the contact about given little knowledge. The topics should cover a wide breadth of subjects
to allow our agents to pick which ones to engage with.
**Parameters**:
- Customer: {customer}
**Note**: {self.__tip_section()}
"""
),
expected_output='A list of broad topics for small talk accompanied by a detailed summary of the event and its relevance.',
agent=agent
)
def gather_sports_info(self, agent, city, team_affinity):
return Task(
description=dedent(
f"""
**Task**: Identify the most relevant and topical sports developments based on a given city
**Description**: Analyze recent games and statistics throughout all sporting teams local to the given city. Your final answer should
be an overarching summary of the most important and popular developments in sports based around the city
**Parameters**:
- City: {city}
- Team Preferences: {team_affinity}
**Note**: {self.__tip_section()}
"""
),
expected_output='A broad summary of the most important and most popular developments in sports centered around the city.',
agent=agent
)
def gather_city_info(self, agent, city, interests):
return Task(
description=dedent(
f"""
**Task**: Gather In-depth City News
**Description**: Compile an in-depth summary of local news, complete with a variety of different topics
that avoid political controversy and can foster conversation. Base these topics off of local
interests, and tailor the results to be great conversation starters. Your final answer should be an
overview of the most important and most recent local news and events.
**Parameters**:
- City: {city}
- Interests: {interests}
**Note**: {self.__tip_section()}
"""
),
expected_output='A detailed summary of the most important and most recent local news and events tailored to generate conversation.',
agent=agent
)