-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallelization_agent.py
More file actions
114 lines (83 loc) · 3.37 KB
/
parallelization_agent.py
File metadata and controls
114 lines (83 loc) · 3.37 KB
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
import asyncio
import json
from strands import Agent, tool
from strands_tools import calculator
from strands.models import BedrockModel
bedrock_model = BedrockModel(
model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
region_name='us-east-1',
temperature=0.3,
)
@tool
def write_linkedIn_post(content: str):
'''
:param content: {"title":"string","key_outcomes":["string"],"cta":"string"}
:return:{"post":"string"}
'''
LINKEDIN_AGENT_SYSTEM_PROMPT = '''
You write LinkedIn-ready announcements that are clear, professional, and skimmable.
Success = a single post with a strong hook, value-focused bullets, and a clear CTA.
Principles: no hashtags in the body, avoid jargon, keep it friendly-professional, 120–220 words max.
'''
linkedin_agent = Agent(
model=bedrock_model,
system_prompt=LINKEDIN_AGENT_SYSTEM_PROMPT,
callback_handler=None
)
response = linkedin_agent(content)
return response
@tool
def write_twitter_post(content: str):
'''
:param content: {"title":"string","key_outcomes":["string"],"cta":"string","max_tweets":5}
:return:{"thread":["string","string","string","string","string"]}
'''
TWITTER_AGENT_SYSTEM_PROMPT = '''
You craft concise, high-signal threads (≤5 tweets) that teach or announce.
Success = a compelling first tweet, 3–4 crisp points, and a closing CTA.
Principles: short sentences, plain language, minimal emojis, lightweight hashtags (≤2 total).
'''
twitter_agent = Agent(
model=bedrock_model,
system_prompt=TWITTER_AGENT_SYSTEM_PROMPT,
callback_handler=None
)
response = twitter_agent(content)
return response
@tool
def write_ig_post(content: str):
"""
:param content:{"title":"string","vibe":"educational|inspirational","cta":"string"}
:return:{"caption":"string","hashtags":["string"]}
"""
IG_AGENT_SYSTEM_PROMPT = '''
You write engaging IG captions with a warm, human tone.
Success = 1–3 short lines, a simple CTA, and a tidy hashtag set.
Principles: keep it friendly and inspirational, no walls of text, ≤10 relevant hashtags.
'''
ig_agent = Agent(
model=bedrock_model,
system_prompt=IG_AGENT_SYSTEM_PROMPT,
callback_handler=None
)
response = ig_agent(content)
return response
SYSTEM_PROMPT = '''
You are an aggregation agent that merges platform-specific drafts into a coherent promo pack.
Success = consistent voice and CTA across platforms, no duplication, cleaned formatting, and de-duplicated hashtags.
Principles: do not rewrite meaning; normalize tone, enforce platform rules (e.g., no hashtags in LinkedIn body), and return a tidy bundle labeled by channel.
'''
'''
{"bundle":{"linkedin":"string","x_thread":["string"],"instagram":{"caption":"string","hashtags":["string"]}},"notes":"string"}
'''
# Initialize our agent without a callback handler
aggregator_agent = Agent(
model=bedrock_model,
system_prompt=SYSTEM_PROMPT,
tools=[write_linkedIn_post, write_ig_post, write_twitter_post],
callback_handler=None
)
# Async function that iterates over streamed agent events
query = "What's the current state of AI in Africa wrt to growth areas. Include encouraging discussions and ideas, in an inspirational tone?"
agent_response = aggregator_agent(json.dumps(query))
print(agent_response)