NikhilSetiya
commited on
Commit
·
501992b
1
Parent(s):
498cc41
Fix: Update image generation and clean config files
Browse files- agent.py +3 -13
- config/system_prompts/ad_copy_prompt.txt +12 -18
agent.py
CHANGED
@@ -45,7 +45,7 @@ def call_groq(system_prompt, user_input):
|
|
45 |
|
46 |
return data['choices'][0]['message']['content']
|
47 |
|
48 |
-
def generate_ad_image(prompt, n_images=1, size="
|
49 |
headers = {
|
50 |
"Authorization": f"Bearer {OPENAI_API_KEY}",
|
51 |
"Content-Type": "application/json"
|
@@ -75,22 +75,12 @@ def ad_copy_agent(product, description, audience, tone):
|
|
75 |
|
76 |
# Extract clean ad copies
|
77 |
ad_copies = []
|
78 |
-
current_ad = []
|
79 |
for line in ad_section.split('\n'):
|
80 |
-
|
81 |
-
|
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):
|
|
|
45 |
|
46 |
return data['choices'][0]['message']['content']
|
47 |
|
48 |
+
def generate_ad_image(prompt, n_images=1, size="1024x1024"):
|
49 |
headers = {
|
50 |
"Authorization": f"Bearer {OPENAI_API_KEY}",
|
51 |
"Content-Type": "application/json"
|
|
|
75 |
|
76 |
# Extract clean ad copies
|
77 |
ad_copies = []
|
|
|
78 |
for line in ad_section.split('\n'):
|
79 |
+
if line.strip():
|
80 |
+
ad_copies.append(line.strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
|
|
82 |
ad_copy_text = '\n'.join(ad_copies)
|
83 |
|
|
|
84 |
return ad_copy_text, image_prompt
|
85 |
|
86 |
def sentiment_agent(social_data):
|
config/system_prompts/ad_copy_prompt.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
You are a senior marketing copywriter specializing in digital ads. Your job is to generate highly persuasive, creative, and audience-tailored ad copy
|
2 |
|
3 |
-
Rules
|
4 |
- Write 3 distinct ad variations.
|
5 |
- Focus on **benefits**, not just features.
|
6 |
- Use emotionally engaging language.
|
@@ -9,21 +9,15 @@ Rules for Ad Copy:
|
|
9 |
- Keep ads under 280 characters.
|
10 |
- If details are missing, infer creatively.
|
11 |
|
12 |
-
|
13 |
-
-
|
14 |
-
-
|
15 |
-
-
|
16 |
-
-
|
17 |
|
18 |
-
|
19 |
-
Ad Copy 1:
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
[ad copy text]
|
24 |
-
|
25 |
-
Ad Copy 3:
|
26 |
-
[ad copy text]
|
27 |
-
|
28 |
-
Image Prompt:
|
29 |
-
[visual description, one prompt only]
|
|
|
1 |
+
You are a senior marketing copywriter specializing in digital ads. Your job is to generate highly persuasive, creative, and audience-tailored ad copy.
|
2 |
|
3 |
+
Rules:
|
4 |
- Write 3 distinct ad variations.
|
5 |
- Focus on **benefits**, not just features.
|
6 |
- Use emotionally engaging language.
|
|
|
9 |
- Keep ads under 280 characters.
|
10 |
- If details are missing, infer creatively.
|
11 |
|
12 |
+
In addition, generate a **single, clear image prompt** for an AI image generator. The image prompt must:
|
13 |
+
- Describe the key visual idea, including subject, mood, background, color, and style.
|
14 |
+
- Be under 50 words.
|
15 |
+
- Specify style tags (e.g., photo-realistic, 3D render, flat vector).
|
16 |
+
- Example: “Photo-realistic image of a joyful young woman jogging through a sunny park, dynamic motion, vibrant colors, DSLR quality, shallow depth of field.”
|
17 |
|
18 |
+
Format your output as:
|
19 |
+
Ad Copy 1: ...
|
20 |
+
Ad Copy 2: ...
|
21 |
+
Ad Copy 3: ...
|
22 |
|
23 |
+
Image Prompt: ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|