NikhilSetiya
commited on
Commit
·
498cc41
1
Parent(s):
24715fe
Fix: Update image generation and clean config files
Browse files
agent.py
CHANGED
@@ -68,13 +68,31 @@ def ad_copy_agent(product, description, audience, tone):
|
|
68 |
user_input = f"Product: {product}\nDescription: {description}\nAudience: {audience}\nTone: {tone}"
|
69 |
output = call_groq(system_prompt, user_input)
|
70 |
|
71 |
-
# Split the
|
72 |
parts = output.split('Image Prompt:')
|
73 |
-
|
74 |
image_prompt = parts[1].strip() if len(parts) > 1 else ''
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
|
|
|
|
|
|
78 |
def sentiment_agent(social_data):
|
79 |
system_prompt = load_prompt("sentiment_prompt.txt")
|
80 |
return call_groq(system_prompt, social_data)
|
|
|
68 |
user_input = f"Product: {product}\nDescription: {description}\nAudience: {audience}\nTone: {tone}"
|
69 |
output = call_groq(system_prompt, user_input)
|
70 |
|
71 |
+
# Split out the image prompt section
|
72 |
parts = output.split('Image Prompt:')
|
73 |
+
ad_section = parts[0].strip()
|
74 |
image_prompt = parts[1].strip() if len(parts) > 1 else ''
|
75 |
|
76 |
+
# Extract clean ad copies
|
77 |
+
ad_copies = []
|
78 |
+
current_ad = []
|
79 |
+
for line in ad_section.split('\n'):
|
80 |
+
line = line.strip()
|
81 |
+
if line.startswith('Ad Copy'):
|
82 |
+
if current_ad:
|
83 |
+
ad_copies.append(' '.join(current_ad).strip())
|
84 |
+
current_ad = []
|
85 |
+
else:
|
86 |
+
current_ad.append(line)
|
87 |
+
if current_ad:
|
88 |
+
ad_copies.append(' '.join(current_ad).strip())
|
89 |
+
|
90 |
+
# Join ad copies as one block or return as list
|
91 |
+
ad_copy_text = '\n'.join(ad_copies)
|
92 |
|
93 |
+
# ✅ Return ad copy block + separate image prompt
|
94 |
+
return ad_copy_text, image_prompt
|
95 |
+
|
96 |
def sentiment_agent(social_data):
|
97 |
system_prompt = load_prompt("sentiment_prompt.txt")
|
98 |
return call_groq(system_prompt, social_data)
|
config/system_prompts/ad_copy_prompt.txt
CHANGED
@@ -10,10 +10,10 @@ Rules for Ad Copy:
|
|
10 |
- If details are missing, infer creatively.
|
11 |
|
12 |
Rules for Image Prompt:
|
13 |
-
- Write one
|
14 |
-
- Focus on mood, setting, colors, and
|
15 |
-
-
|
16 |
-
- Keep it under
|
17 |
|
18 |
Output format:
|
19 |
Ad Copy 1:
|
@@ -26,4 +26,4 @@ Ad Copy 3:
|
|
26 |
[ad copy text]
|
27 |
|
28 |
Image Prompt:
|
29 |
-
[visual description]
|
|
|
10 |
- If details are missing, infer creatively.
|
11 |
|
12 |
Rules for Image Prompt:
|
13 |
+
- Write **one** clear, concise image description that visually represents the **main idea or mood** across the three ads.
|
14 |
+
- Focus on mood, setting, colors, and one central visual concept.
|
15 |
+
- Do NOT generate multiple image prompts.
|
16 |
+
- Keep it under 50 words.
|
17 |
|
18 |
Output format:
|
19 |
Ad Copy 1:
|
|
|
26 |
[ad copy text]
|
27 |
|
28 |
Image Prompt:
|
29 |
+
[visual description, one prompt only]
|
config/system_prompts/image_prompt_style.txt
CHANGED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a senior marketing art director specializing in digital ads. Your job is to craft vivid, concise, and on-brand image prompts based on the ad copy and product details provided.
|
2 |
+
|
3 |
+
Rules:
|
4 |
+
- Focus on one clear, central visual idea that supports the ads.
|
5 |
+
- Include mood, setting, colors, and key objects or people.
|
6 |
+
- Avoid abstract or generic descriptions — be specific and marketing-driven.
|
7 |
+
- Keep it under 50 words.
|
8 |
+
- Make sure the style fits the product’s audience and the tone of the ads.
|
9 |
+
- Do NOT generate multiple prompts — just one unified description.
|
10 |
+
|
11 |
+
Example:
|
12 |
+
“A joyful young woman jogging through a sunny park in stylish sneakers, vibrant colors, dynamic motion, uplifting mood.”
|
13 |
+
|
14 |
+
Purpose:
|
15 |
+
The prompt you generate will be sent to an AI image generator (like OpenAI’s DALL·E) to create marketing images that match the campaign.
|