sushilideaclan01 commited on
Commit
1afa519
·
1 Parent(s): 3231378

Add visual style display to ad details and update API types

Browse files

- Enhanced the AdDetailPage to display the visual style of ads if available, improving user experience.
- Updated the AdCreativeDB interface to include an optional visual_style property for better data representation.
- Modified the generator service to incorporate visual style in metadata during ad generation, ensuring consistency across the application.

frontend/app/gallery/[id]/page.tsx CHANGED
@@ -393,6 +393,12 @@ export default function AdDetailPage() {
393
  <p className="font-semibold text-gray-800">{formatDate(ad.created_at)}</p>
394
  </div>
395
  )}
 
 
 
 
 
 
396
  </div>
397
  </div>
398
  </div>
 
393
  <p className="font-semibold text-gray-800">{formatDate(ad.created_at)}</p>
394
  </div>
395
  )}
396
+ {ad.metadata?.visual_style && (
397
+ <div className="bg-gradient-to-br from-indigo-50 to-blue-50 rounded-xl p-3 border border-indigo-100">
398
+ <p className="text-indigo-600 text-xs font-medium mb-1">Visual Style</p>
399
+ <p className="font-semibold text-gray-800">{ad.metadata.visual_style}</p>
400
+ </div>
401
+ )}
402
  </div>
403
  </div>
404
  </div>
frontend/types/api.ts CHANGED
@@ -192,6 +192,7 @@ export interface AdCreativeDB {
192
  is_corrected?: boolean;
193
  correction_date?: string | null;
194
  corrections?: CorrectionData | null;
 
195
  [key: string]: any;
196
  } | null;
197
  r2_url?: string | null;
 
192
  is_corrected?: boolean;
193
  correction_date?: string | null;
194
  corrections?: CorrectionData | null;
195
+ visual_style?: string | null;
196
  [key: string]: any;
197
  } | null;
198
  r2_url?: string | null;
services/generator.py CHANGED
@@ -1047,22 +1047,22 @@ CRITICAL REMINDERS:
1047
  text_overlay_section = ""
1048
  if include_text_overlay:
1049
  text_overlay_section = f"""
1050
- === HEADLINE TEXT (OPTIONAL - natural text in scene, NOT overlay) ===
1051
- IMPORTANT: If including text, it should be part of the natural scene, NOT an overlay.
1052
 
1053
- Headline to include naturally: "{headline}"
1054
 
1055
- Text requirements (natural integration only):
1056
- - Text should appear as part of the scene (on documents, signs, surfaces, etc.)
 
1057
  - Position: {text_position}
1058
  - Style: {text_color}
1059
- - Ensure readability
1060
- - Spell every word correctly
1061
- - CRITICAL: Text must be part of the scene, NOT an overlay on top
1062
  - NO decorative borders, boxes, or frames around text
1063
  - NO banners, badges, or logos
1064
- - NO overlay boxes or rectangular overlays
1065
- - Text should look like it naturally belongs in the scene
1066
  """
1067
  else:
1068
  text_overlay_section = """
@@ -1176,18 +1176,21 @@ DOCUMENTS (if present):
1176
  - NO gibberish, placeholder text, or random characters in chat bubbles or documents
1177
  - NO "lorem ipsum", placeholder text, or meaningless character strings
1178
  - If using a container format, use ONLY that one container type - NO mixing
 
 
 
1179
 
1180
  === OUTPUT ===
1181
- Create a scroll-stopping image that feels authentic and organic. {f'The headline "{headline}" should be included if text overlay is enabled.' if include_text_overlay else 'Focus on the visual scene without text overlay.'} The image should feel like real content - NOT like a designed advertisement. Use only the elements that fit naturally - don't force every element into every image.
1182
 
1183
  CRITICAL REQUIREMENTS:
1184
  - NO decorative borders, frames, or boxes
1185
  - NO banners, badges, or logos in corners
1186
  - NO overlay boxes or rectangular overlays
1187
- - NO news-style chyrons or tickers
1188
- - NO graphic design elements added on top
1189
  - Focus on the natural, authentic scene only
1190
- - If text is included, it should be part of the natural scene, not in a decorative box"""
1191
 
1192
  # Refine and clean the prompt before sending
1193
  refined_prompt = self._refine_image_prompt(prompt)
@@ -1534,6 +1537,7 @@ CRITICAL REQUIREMENTS:
1534
  "composition": composition,
1535
  "hooks_inspiration": hooks,
1536
  "visual_styles": visual_styles,
 
1537
  }
1538
 
1539
  # Save to database (save EACH image as a separate record for gallery visibility)
@@ -1840,7 +1844,12 @@ CONCEPT: {concept['name']}
1840
  concept_visual=concept.get("visual"),
1841
  concept_category=concept.get("category"),
1842
  generation_method="angle_concept_matrix",
1843
- metadata={"generation_method": "angle_concept_matrix", "variation_index": img_idx, "total_variations": len(images)},
 
 
 
 
 
1844
  )
1845
  if db_id:
1846
  saved_ad_ids.append(db_id)
 
1047
  text_overlay_section = ""
1048
  if include_text_overlay:
1049
  text_overlay_section = f"""
1050
+ === HEADLINE TEXT (natural text in scene, NOT overlay) ===
1051
+ IMPORTANT: Include this text ONLY ONCE in the image, as part of the natural scene.
1052
 
1053
+ Text to include: "{headline}"
1054
 
1055
+ CRITICAL TEXT RULES:
1056
+ - Include the text ONLY ONCE - do NOT repeat or duplicate it anywhere
1057
+ - Text should appear in ONE location only (on a document, sign, or surface in the scene)
1058
  - Position: {text_position}
1059
  - Style: {text_color}
1060
+ - Ensure readability and correct spelling
1061
+ - Text must be part of the scene, NOT an overlay on top
 
1062
  - NO decorative borders, boxes, or frames around text
1063
  - NO banners, badges, or logos
1064
+ - Do NOT show the same message in multiple formats or locations
1065
+ - If text contains numbers/prices, show them ONCE only
1066
  """
1067
  else:
1068
  text_overlay_section = """
 
1176
  - NO gibberish, placeholder text, or random characters in chat bubbles or documents
1177
  - NO "lorem ipsum", placeholder text, or meaningless character strings
1178
  - If using a container format, use ONLY that one container type - NO mixing
1179
+ - NO DUPLICATE TEXT - do not show the same text/message in multiple places
1180
+ - NO repeating headlines or prices in different formats or locations
1181
+ - Text should appear ONCE only, not multiple times in the image
1182
 
1183
  === OUTPUT ===
1184
+ Create a scroll-stopping image that feels authentic and organic. {'Include the headline text ONCE as specified above - do NOT duplicate it.' if include_text_overlay else 'Focus on the visual scene without text.'} The image should feel like real content - NOT like a designed advertisement.
1185
 
1186
  CRITICAL REQUIREMENTS:
1187
  - NO decorative borders, frames, or boxes
1188
  - NO banners, badges, or logos in corners
1189
  - NO overlay boxes or rectangular overlays
1190
+ - NO duplicate text - any text should appear ONLY ONCE
1191
+ - NO repeating the same message in different formats
1192
  - Focus on the natural, authentic scene only
1193
+ - If text is included, show it in ONE location only, not multiple places"""
1194
 
1195
  # Refine and clean the prompt before sending
1196
  refined_prompt = self._refine_image_prompt(prompt)
 
1537
  "composition": composition,
1538
  "hooks_inspiration": hooks,
1539
  "visual_styles": visual_styles,
1540
+ "visual_style": visual_style_data.get("name") if visual_style_data else None,
1541
  }
1542
 
1543
  # Save to database (save EACH image as a separate record for gallery visibility)
 
1844
  concept_visual=concept.get("visual"),
1845
  concept_category=concept.get("category"),
1846
  generation_method="angle_concept_matrix",
1847
+ metadata={
1848
+ "generation_method": "angle_concept_matrix",
1849
+ "variation_index": img_idx,
1850
+ "total_variations": len(images),
1851
+ "visual_style": concept.get("name"), # Use concept name as visual style for matrix generation
1852
+ },
1853
  )
1854
  if db_id:
1855
  saved_ad_ids.append(db_id)
services/third_flow.py CHANGED
@@ -605,6 +605,7 @@ CRITICAL: The image MUST be appropriate for {niche} niche."""
605
  2. Use "Soft Education," Not Sales. The body should feel informational, not promotional.
606
  3. Add Friction Reducers. You must explicitly reduce effort and risk.
607
  4. Body Should NOT Contain the CTA. CTA belongs in the button, not the body.
 
608
 
609
  Role of Description: Reduce friction and justify the click.
610
  1. Never Repeat the Title. The description should complete the thought.
@@ -620,7 +621,10 @@ CRITICAL: The image MUST be appropriate for {niche} niche."""
620
  "type": "text",
621
  "text": f"""Following is the creative strategy:
622
  {strategy_str}
623
- Provide the title and description prompt for the given creative strategy."""
 
 
 
624
  }
625
  ]
626
  }
 
605
  2. Use "Soft Education," Not Sales. The body should feel informational, not promotional.
606
  3. Add Friction Reducers. You must explicitly reduce effort and risk.
607
  4. Body Should NOT Contain the CTA. CTA belongs in the button, not the body.
608
+ 5. LENGTH REQUIREMENT: The body MUST be at least 150-250 words. Write a compelling, detailed narrative that tells a story, builds emotional connection, and provides enough context to persuade the reader. Include specific details, relatable scenarios, and a clear progression of ideas.
609
 
610
  Role of Description: Reduce friction and justify the click.
611
  1. Never Repeat the Title. The description should complete the thought.
 
621
  "type": "text",
622
  "text": f"""Following is the creative strategy:
623
  {strategy_str}
624
+
625
+ Provide the title, body, and description for the given creative strategy.
626
+
627
+ IMPORTANT: The body must be 150-250 words long - write a detailed, compelling narrative that tells a story and builds emotional connection with the reader."""
628
  }
629
  ]
630
  }