-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
132 lines (111 loc) · 5.54 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
from textwrap import dedent
from crewai import Task
class NewsTasks:
def retrieve_news_task(self, agent, news_topic):
return Task(
description=dedent(f"""
Retrieve all news articles related to the topic: {news_topic}.
Provide a list of articles with their titles, sources, and publication dates.
Focus on finding comprehensive and reliable sources.
Your final answer should be a detailed list of news articles with:
- Titles
- Sources
- Publication dates
- Brief description of each article
"""),
agent=agent,
expected_output="Comprehensive list of news articles related to the topic"
)
def validate_and_summarize_task(self, agent, news_content, news_topic):
return Task(
description=dedent(f"""
Validate and summarize the news content about: {news_topic}
Content to validate: {news_content}
Your tasks:
1. Verify the information across multiple sources
2. Fact-check key claims
3. Create a high-level summary of all verified information
4. Highlight any discrepancies or conflicting information
5. Provide a final, comprehensive summary of the topic
Your final answer should include:
- Validation results
- Comprehensive summary
- Key findings
- Any notable discrepancies
"""),
agent=agent,
expected_output="Validated and summarized news content"
)
def create_post_task(self, agent, news_content, target_audience, platform,
tone, word_count, language, include_emojis, special_requests):
emoji_instruction = "Include relevant emojis throughout the post." if include_emojis else ""
special_instruction = f"\nAdditional requirements: {special_requests}" if special_requests else ""
return Task(
description=dedent(f"""
Create a {platform} post based on the following validated news content:
{news_content}
Target Audience: {target_audience}
Platform: {platform}
Tone: {tone if tone else 'Use appropriate tone for the platform and audience'}
Length: {word_count if word_count else 'Use appropriate length for the platform'}
Language: {language}
{emoji_instruction}
{special_instruction}
Ensure the post:
1. Is optimized for the specified platform
2. Speaks directly to the target audience
3. Uses appropriate formatting and structure
4. Includes relevant hashtags if appropriate
5. Follows platform-specific best practices
6. Includes engaging statistics or data when available
7. Uses quotes and highlights for important information
8. Incorporates a clear call-to-action
Format your response in markdown with:
- Headers using #
- Bold text using **
- Lists using - or 1.
- Quote blocks using >
- Code/special formatting using `
- Links in proper markdown format [text](url)
- Statistics and numbers highlighted in **bold**
Structure the output as:
# Generated Post for {platform}
## Post Content
[The actual post content]
## Post Details
- **Platform**: [platform]
- **Target Audience**: [audience]
- **Tone**: [tone]
- **Length**: [word count]
## Engagement Elements
- Key statistics used
- Quotes included
- Call-to-action
## Hashtags and Keywords
[relevant hashtags and keywords]
Your final answer should be the complete markdown-formatted content.
"""),
agent=agent
)
def verify_news_authenticity_task(self, agent, news_content):
return Task(
description=dedent(f"""
Analyze the following news content for authenticity:
{news_content}
Your tasks:
1. Cross-reference the information with multiple reliable sources
2. Check for signs of misinformation or fake news
3. Verify quotes, statistics, and claims
4. Analyze the credibility of sources
5. Check publication dates and timeline consistency
6. Look for manipulated media if mentioned
Provide a detailed analysis including:
- Authenticity score (0-100%)
- Evidence supporting or refuting claims
- List of verified sources
- Red flags or inconsistencies found
- Recommendations for readers
Format your response in a clear, structured manner.
"""),
agent=agent
)