faizee07 commited on
Commit
2ae2c3e
·
verified ·
1 Parent(s): 025d186

Create crews/tasks.py

Browse files
Files changed (1) hide show
  1. crews/tasks.py +73 -0
crews/tasks.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Task
2
+ from crews.agents import content_writer_agent, image_prompt_agent, quality_assurance_agent
3
+
4
+ def create_content_tasks(rss_content: str, rss_title: str):
5
+ """Create CrewAI tasks for content generation"""
6
+
7
+ write_caption_task = Task(
8
+ description=f"""Based on this RSS feed content, create an engaging Instagram post:
9
+
10
+ Title: {rss_title}
11
+ Content: {rss_content}
12
+
13
+ Requirements:
14
+ - Write a compelling caption (150-300 words)
15
+ - Include 10-15 relevant hashtags
16
+ - Suggest 3-5 carousel slide topics if applicable
17
+ - Keep the tone professional yet engaging
18
+ - Include a clear call-to-action
19
+
20
+ Output your response in valid JSON format with these exact keys:
21
+ {{
22
+ "caption": "your caption here",
23
+ "carousel_items": ["slide 1 text", "slide 2 text", ...],
24
+ "hashtags": ["hashtag1", "hashtag2", ...]
25
+ }}
26
+ """,
27
+ agent=content_writer_agent,
28
+ expected_output="JSON object with caption, carousel_items, and hashtags"
29
+ )
30
+
31
+ create_image_prompt_task = Task(
32
+ description=f"""Create a detailed image generation prompt for this Instagram post:
33
+
34
+ Title: {rss_title}
35
+ Content: {rss_content}
36
+
37
+ Requirements:
38
+ - Describe a visually striking image that represents the content
39
+ - Include style, colors, composition, and mood
40
+ - Make it suitable for Instagram's square or 4:5 format
41
+ - Keep it under 200 words
42
+
43
+ Output in JSON format:
44
+ {{
45
+ "image_prompt": "detailed prompt here"
46
+ }}
47
+ """,
48
+ agent=image_prompt_agent,
49
+ expected_output="JSON object with image_prompt"
50
+ )
51
+
52
+ quality_check_task = Task(
53
+ description="""Review and refine the generated content to ensure:
54
+
55
+ 1. Caption is engaging and within character limits
56
+ 2. Hashtags are relevant and trending
57
+ 3. Image prompt is clear and actionable
58
+ 4. Content follows Instagram best practices
59
+
60
+ Combine all outputs into a single validated JSON object:
61
+ {{
62
+ "caption": "refined caption",
63
+ "carousel_items": ["item1", "item2", ...],
64
+ "hashtags": ["tag1", "tag2", ...],
65
+ "image_prompt": "refined prompt"
66
+ }}
67
+ """,
68
+ agent=quality_assurance_agent,
69
+ expected_output="Final validated JSON object with all fields",
70
+ context=[write_caption_task, create_image_prompt_task]
71
+ )
72
+
73
+ return [write_caption_task, create_image_prompt_task, quality_check_task]