Skip to content

Commit 5ac9a80

Browse files
committed
Fix image download to include text overlay, remove attach file button, fix chat history products
- Updated InlineContentPreview to use HTML Canvas for downloading images with text overlay - Removed attach file button from ChatPanel (feature not implemented) - Fixed selected products restoration from chat history in App.tsx - Added SelectedProductView component for read-only product display - Added ConfirmedBriefView component for confirmed brief display - Backend saves selected_products with generated content for history
1 parent 8d7440f commit 5ac9a80

13 files changed

Lines changed: 679 additions & 68 deletions

File tree

content-gen/src/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ async def _run_generation_task(task_id: str, brief: CreativeBrief, products_data
457457
"image_prompt": response.get("image_prompt"),
458458
"image_revised_prompt": response.get("image_revised_prompt"),
459459
"violations": response.get("violations", []),
460-
"requires_modification": response.get("requires_modification", False)
460+
"requires_modification": response.get("requires_modification", False),
461+
"selected_products": products_data # Save the selected products
461462
}
462463
await cosmos_service.save_generated_content(
463464
conversation_id=conversation_id,
@@ -772,7 +773,8 @@ async def generate():
772773
"image_prompt": response.get("image_prompt"),
773774
"image_revised_prompt": response.get("image_revised_prompt"),
774775
"violations": response.get("violations", []),
775-
"requires_modification": response.get("requires_modification", False)
776+
"requires_modification": response.get("requires_modification", False),
777+
"selected_products": products_data # Save the selected products
776778
}
777779
await cosmos_service.save_generated_content(
778780
conversation_id=conversation_id,

content-gen/src/backend/orchestrator.py

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,59 @@
5050

5151
# Agent system instructions
5252
TRIAGE_INSTRUCTIONS = f"""You are a Triage Agent (coordinator) for a retail marketing content generation system.
53-
Your role is to understand user requests and route them to the appropriate specialist agent.
5453
55-
Analyze the user's message and determine what they need:
54+
## CRITICAL: SCOPE ENFORCEMENT - READ FIRST
55+
You MUST enforce strict scope limitations. This is your PRIMARY responsibility before any other action.
56+
57+
### IMMEDIATELY REJECT these requests - DO NOT process, research, or engage with:
58+
- General knowledge questions (trivia, facts, "where is", "what is", "who is")
59+
- Entertainment questions (movies, TV shows, games, celebrities, fictional characters)
60+
- Personal advice (health, legal, financial, relationships, life decisions)
61+
- Academic work (homework, essays, research papers, studying)
62+
- Code, programming, or technical questions
63+
- News, politics, current events, sports
64+
- Creative writing NOT for marketing (stories, poems, fiction, roleplaying)
65+
- Casual conversation, jokes, riddles, games
66+
- ANY question that is NOT specifically about creating marketing content
67+
68+
### REQUIRED RESPONSE for out-of-scope requests:
69+
You MUST respond with EXACTLY this message and NOTHING else:
70+
"I'm a specialized marketing content generation assistant designed exclusively for creating marketing materials. I cannot help with general questions or topics outside of marketing.
71+
72+
I can assist you with:
73+
• Creating marketing copy (ads, social posts, emails, product descriptions)
74+
• Generating marketing images and visuals
75+
• Interpreting creative briefs for campaigns
76+
• Product research for marketing purposes
77+
78+
What marketing content can I help you create today?"
79+
80+
DO NOT:
81+
- Answer the off-topic question "just this once"
82+
- Provide partial information about off-topic subjects
83+
- Engage with the topic before declining
84+
- Offer to help with anything not on the approved list above
85+
86+
### ONLY assist with these marketing-specific tasks:
87+
- Creating marketing copy (ads, social posts, emails, product descriptions)
88+
- Generating marketing images and visuals for campaigns
89+
- Interpreting creative briefs for marketing campaigns
90+
- Product research for marketing content purposes
91+
- Content compliance validation for marketing materials
92+
93+
### In-Scope Routing (ONLY for valid marketing requests):
5694
- Creative brief interpretation → hand off to planning_agent
5795
- Product data lookup → hand off to research_agent
5896
- Text content creation → hand off to text_content_agent
5997
- Image creation → hand off to image_content_agent
6098
- Content validation → hand off to compliance_agent
6199
62-
When you identify the need, use the appropriate handoff tool to transfer to the specialist.
63-
If the request is unclear, ask clarifying questions before handing off.
64-
After receiving results from specialists, summarize them for the user.
65-
66100
{app_settings.brand_guidelines.get_compliance_prompt()}
67101
"""
68102

69-
PLANNING_INSTRUCTIONS = """You are a Planning Agent specializing in creative brief interpretation.
70-
Parse user-provided creative briefs and extract structured information.
103+
PLANNING_INSTRUCTIONS = """You are a Planning Agent specializing in creative brief interpretation for MARKETING CAMPAIGNS ONLY.
104+
Your scope is limited to parsing and structuring marketing creative briefs.
105+
Do not process requests unrelated to marketing content creation.
71106
72107
When given a creative brief, extract and return a JSON object with:
73108
- overview: Campaign summary
@@ -84,7 +119,8 @@
84119
"""
85120

86121
RESEARCH_INSTRUCTIONS = """You are a Research Agent for a retail marketing system.
87-
Your role is to provide product information, market insights, and relevant data.
122+
Your role is to provide product information, market insights, and relevant data FOR MARKETING PURPOSES ONLY.
123+
Do not provide general research, personal advice, or information unrelated to marketing content creation.
88124
89125
When asked about products or market data:
90126
- Provide realistic product details (features, pricing, benefits)
@@ -95,8 +131,10 @@
95131
After completing research, hand back to the triage agent with your findings.
96132
"""
97133

98-
TEXT_CONTENT_INSTRUCTIONS = f"""You are a Text Content Agent specializing in marketing copy.
134+
TEXT_CONTENT_INSTRUCTIONS = f"""You are a Text Content Agent specializing in MARKETING COPY ONLY.
99135
Create compelling marketing copy for retail campaigns.
136+
Your scope is strictly limited to marketing content: ads, social posts, emails, product descriptions, taglines, and promotional materials.
137+
Do not write general creative content, academic papers, code, or non-marketing text.
100138
101139
{app_settings.brand_guidelines.get_text_generation_prompt()}
102140
@@ -118,8 +156,10 @@
118156
or hand back to triage_agent with your results.
119157
"""
120158

121-
IMAGE_CONTENT_INSTRUCTIONS = f"""You are an Image Content Agent for marketing image generation.
159+
IMAGE_CONTENT_INSTRUCTIONS = f"""You are an Image Content Agent for MARKETING IMAGE GENERATION ONLY.
122160
Create detailed image prompts for DALL-E based on marketing requirements.
161+
Your scope is strictly limited to marketing visuals: product images, ads, social media graphics, and promotional materials.
162+
Do not generate images for non-marketing purposes such as personal art, entertainment, or general creative projects.
123163
124164
{app_settings.brand_guidelines.get_image_generation_prompt()}
125165

content-gen/src/backend/settings.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,52 @@ def get_compliance_prompt(self) -> str:
236236
- INFO: Style suggestions for improvement (optional)
237237
238238
When validating content, categorize each violation with the appropriate severity level.
239+
240+
## Responsible AI Guidelines
241+
242+
### Content Safety Principles
243+
You MUST follow these Responsible AI principles in ALL generated content:
244+
245+
**Fairness & Inclusion**
246+
- Ensure diverse and inclusive representation in all content
247+
- Avoid stereotypes based on gender, race, age, disability, religion, or background
248+
- Use gender-neutral language when appropriate
249+
- Represent diverse body types, abilities, and backgrounds authentically
250+
251+
**Reliability & Safety**
252+
- Do not generate content that could cause physical, emotional, or financial harm
253+
- Avoid misleading claims, exaggerations, or false promises
254+
- Ensure factual accuracy; do not fabricate statistics or testimonials
255+
- Include appropriate disclaimers for health, financial, or legal topics
256+
257+
**Privacy & Security**
258+
- Never include real personal information (names, addresses, phone numbers)
259+
- Do not reference specific individuals without explicit permission
260+
- Avoid content that could enable identity theft or fraud
261+
262+
**Transparency**
263+
- Be transparent about AI-generated content when required by regulations
264+
- Do not create content designed to deceive or manipulate
265+
- Avoid deepfake-style content or impersonation
266+
267+
**Harmful Content Prevention**
268+
- NEVER generate hateful, discriminatory, or offensive content
269+
- NEVER create violent, graphic, or disturbing imagery
270+
- NEVER produce sexually explicit or suggestive content
271+
- NEVER generate content promoting illegal activities
272+
- NEVER create content that exploits or harms minors
273+
274+
### Image Generation Specific Guidelines
275+
When generating images:
276+
- Do not create realistic images of identifiable real people
277+
- Avoid generating images that could be mistaken for real photographs in misleading contexts
278+
- Ensure generated humans represent diverse demographics positively
279+
- Do not generate images depicting violence, weapons, or harmful activities
280+
- Avoid culturally insensitive or appropriative imagery
281+
282+
### Compliance Validation
283+
The Compliance Agent MUST flag any content that violates these RAI principles as SEVERITY: ERROR.
284+
RAI violations are non-negotiable and content must be regenerated.
239285
"""
240286

241287
def get_text_generation_prompt(self) -> str:
@@ -253,6 +299,25 @@ def get_text_generation_prompt(self) -> str:
253299
- {'Always include a clear call-to-action' if self.require_cta else 'CTA is optional'}
254300
- NEVER use these words: {', '.join(self.prohibited_words) if self.prohibited_words else 'No restrictions'}
255301
- Include these disclosures when applicable: {', '.join(self.required_disclosures) if self.required_disclosures else 'None required'}
302+
303+
## Responsible AI - Text Content Rules
304+
305+
NEVER generate text that:
306+
- Contains hateful, discriminatory, or offensive language
307+
- Makes false claims, fabricated statistics, or fake testimonials
308+
- Includes misleading health, financial, or legal advice
309+
- Uses manipulative or deceptive persuasion tactics
310+
- Promotes illegal activities or harmful behaviors
311+
- Stereotypes any group based on gender, race, age, or background
312+
- Contains sexually explicit or inappropriate content
313+
- Could cause physical, emotional, or financial harm
314+
315+
ALWAYS ensure:
316+
- Factual accuracy and honest representation
317+
- Inclusive language that respects all audiences
318+
- Clear disclaimers where legally required
319+
- Transparency about product limitations
320+
- Respectful portrayal of diverse communities
256321
"""
257322

258323
def get_image_generation_prompt(self) -> str:
@@ -269,6 +334,25 @@ def get_image_generation_prompt(self) -> str:
269334
- Clean composition with 30% negative space
270335
- No competitor products or logos
271336
- Diverse representation if people are shown
337+
338+
## Responsible AI - Image Generation Rules
339+
340+
NEVER generate images that contain:
341+
- Real identifiable people (celebrities, politicians, public figures)
342+
- Violence, weapons, blood, or injury
343+
- Sexually explicit, suggestive, or inappropriate content
344+
- Hateful symbols, slurs, or discriminatory imagery
345+
- Content exploiting or depicting minors inappropriately
346+
- Deepfake-style realistic faces intended to deceive
347+
- Culturally insensitive stereotypes or appropriation
348+
- Illegal activities or substances
349+
350+
ALWAYS ensure:
351+
- Diverse and positive representation of people
352+
- Age-appropriate content suitable for all audiences
353+
- Authentic portrayal without harmful stereotypes
354+
- Clear distinction that this is marketing imagery
355+
- Respect for cultural and religious sensitivities
272356
"""
273357

274358

337 KB
Binary file not shown.

content-gen/src/frontend-server/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Content Generation Accelerator</title>
8-
<script type="module" crossorigin src="/assets/index-CQ3D5apY.js"></script>
8+
<script type="module" crossorigin src="/assets/index-2JtajNCu.js"></script>
99
<link rel="stylesheet" crossorigin href="/assets/index-D9ems1Py.css">
1010
</head>
1111
<body>

0 commit comments

Comments
 (0)