Claude commited on
Commit
fe97795
ยท
1 Parent(s): e2cbbd9

Fix AC3: Force AI to generate cards in variants + add debug logging

Browse files
Files changed (1) hide show
  1. agents/flutter_screen_generator.py +42 -58
agents/flutter_screen_generator.py CHANGED
@@ -608,91 +608,71 @@ JSON Plan:"""
608
  cards_list = card_suggestions.get(app_type, card_suggestions["generic"])
609
  cards_str = ", ".join(cards_list)
610
 
611
- prompt = f"""Genera UNA home page per l'app {app_type}.
612
- Crea 4 VERSIONI DIVERSE della stessa home page, ognuna con uno stile visivo differente.
613
 
614
- PALETTE COLORI:
615
  - Primary: {theme_summary['primary']}
616
  - Secondary: {theme_summary['secondary']}
617
  - Style: {theme_summary['style']}
618
 
619
- TASK: Crea 4 versioni della home page dell'app {app_type}, ognuna con:
620
- - Layout diverso (grid, lista, hero card, timeline)
621
- - Background diverso (scegli tra i 30 disponibili sotto)
622
- - Header diverso (minimal, stats, tabs, etc)
623
- - Footer diverso (floating fab, animated pills, etc)
624
- - Cards diverse (3-6 cards per versione)
625
-
626
  BACKGROUNDS disponibili:
627
  {bg_list}
628
 
629
  LAYOUTS disponibili:
630
- - grid_2x2: Griglia 2 colonne per metriche/dashboard
631
- - vertical_list: Lista verticale scrollabile classica
632
- - hero_card: UNA card grande in alto + 2-3 card piccole sotto
633
- - timeline: Timeline verticale per eventi cronologici
634
- - featured_grid: UN elemento grande + griglia di 4-6 elementi piccoli
635
-
636
- HEADERS disponibili:
637
- - minimal: Solo titolo
638
- - avatar_search: Avatar + barra ricerca
639
- - tabs: Tab orizzontali
640
- - stats_header: Mostra metriche chiave
641
-
642
- FOOTERS disponibili:
643
- - minimal_icons: Solo icone
644
- - floating_fab: Bottone FAB centrale
645
- - animated_pills: Animazioni smooth
646
- - classic_expanded: Icone + etichette
647
- - gesture_bar: Barra swipe iOS
648
-
649
- CARDS per app {app_type}:
650
  {cards_str}
651
 
652
- REGOLE:
653
- 1. Ogni versione deve avere layout_type DIVERSO
654
- 2. Ogni versione deve avere background DIVERSO
655
- 3. Scegli 3-6 cards dalla lista sopra in base al layout
656
- 4. Personalizza i testi per l'app {app_type}
 
657
 
658
- Output ONLY valid JSON:
659
  {{
660
  "variants": [
661
  {{
662
- "name": "Variant Name",
663
- "description": "Short description",
664
  "layout_type": "grid_2x2",
665
- "background": "waves_smooth",
666
  "header": "stats_header",
667
- "footer": "floating_fab",
668
- "cards": ["card1", "card2", "card3", "card4"],
669
  "texts": {{
670
- "header_title": "Personalized title for {app_type}",
671
- "header_subtitle": "Optional subtitle",
672
- "footer_labels": ["Label1", "Label2", "Label3", "Label4", "Label5"]
673
- }},
674
- "reasoning": "Why this combination works"
675
  }},
676
  {{
677
- "name": "Another Variant",
678
- "description": "Different approach",
679
  "layout_type": "hero_card",
680
- "background": "gradient_mesh",
681
  "header": "minimal",
682
- "footer": "animated_pills",
683
- "cards": ["different1", "different2", "different3"],
684
  "texts": {{
685
- "header_title": "Different title for {app_type}",
686
- "header_subtitle": "Different subtitle",
687
- "footer_labels": ["Home", "Explore", "Settings", "Profile", "More"]
688
- }},
689
- "reasoning": "Different background and components"
690
  }},
691
- ...2 more variants with DIFFERENT layout_type, backgrounds, cards and personalized texts
692
  ]
693
  }}
694
 
695
- JSON:"""
696
 
697
  try:
698
  # Call DeepSeek API
@@ -709,6 +689,10 @@ JSON:"""
709
  variants = result["variants"][:4] # Max 4
710
  print(f"โœ… AI generated {len(variants)} variants from DeepSeek")
711
  print(f"๐Ÿ” DEBUG: Variant names: {[v.get('name') for v in variants]}")
 
 
 
 
712
  return variants
713
  else:
714
  print("โš ๏ธ AI response invalid, using fallback")
 
608
  cards_list = card_suggestions.get(app_type, card_suggestions["generic"])
609
  cards_str = ", ".join(cards_list)
610
 
611
+ prompt = f"""Genera UNA home page per l'app {app_type} in 4 VERSIONI DIVERSE.
 
612
 
613
+ PALETTE:
614
  - Primary: {theme_summary['primary']}
615
  - Secondary: {theme_summary['secondary']}
616
  - Style: {theme_summary['style']}
617
 
 
 
 
 
 
 
 
618
  BACKGROUNDS disponibili:
619
  {bg_list}
620
 
621
  LAYOUTS disponibili:
622
+ - grid_2x2: Griglia 2 colonne
623
+ - vertical_list: Lista verticale
624
+ - hero_card: UNA card grande + piccole
625
+ - timeline: Timeline verticale
626
+
627
+ HEADERS: minimal, avatar_search, tabs, stats_header
628
+ FOOTERS: minimal_icons, floating_fab, animated_pills, classic_expanded, gesture_bar
629
+
630
+ CARDS OBBLIGATORIE (SCEGLI 3-6 DALLA LISTA):
 
 
 
 
 
 
 
 
 
 
 
631
  {cards_str}
632
 
633
+ REGOLE IMPORTANTI:
634
+ 1. OGNI variante DEVE avere layout_type DIVERSO
635
+ 2. OGNI variante DEVE avere background DIVERSO
636
+ 3. OGNI variante DEVE avere 3-6 CARDS dalla lista sopra
637
+ 4. Le cards devono essere DIVERSE per ogni variante
638
+ 5. Personalizza i testi per {app_type}
639
 
640
+ ESEMPIO JSON (USA CARDS DALLA LISTA SOPRA!):
641
  {{
642
  "variants": [
643
  {{
644
+ "name": "Dashboard Grid",
645
+ "description": "Grid layout for metrics",
646
  "layout_type": "grid_2x2",
647
+ "background": "gradient_linear",
648
  "header": "stats_header",
649
+ "footer": "minimal_icons",
650
+ "cards": ["workout_exercise", "step_counter", "calorie_goal", "heart_rate"],
651
  "texts": {{
652
+ "header_title": "Fitness Tracker",
653
+ "header_subtitle": "Today's Progress",
654
+ "footer_labels": ["Home", "Stats", "Goals", "Profile", "More"]
655
+ }}
 
656
  }},
657
  {{
658
+ "name": "Hero Variant",
659
+ "description": "Hero card focused",
660
  "layout_type": "hero_card",
661
+ "background": "waves_smooth",
662
  "header": "minimal",
663
+ "footer": "floating_fab",
664
+ "cards": ["achievement_badge", "weight_progress", "sleep_tracker"],
665
  "texts": {{
666
+ "header_title": "Your Progress",
667
+ "header_subtitle": "",
668
+ "footer_labels": ["Activity", "Stats", "Settings", "Profile", "Menu"]
669
+ }}
 
670
  }},
671
+ ...2 more variants (TOTAL 4) with DIFFERENT layout_type, backgrounds, cards
672
  ]
673
  }}
674
 
675
+ Output JSON:"""
676
 
677
  try:
678
  # Call DeepSeek API
 
689
  variants = result["variants"][:4] # Max 4
690
  print(f"โœ… AI generated {len(variants)} variants from DeepSeek")
691
  print(f"๐Ÿ” DEBUG: Variant names: {[v.get('name') for v in variants]}")
692
+ # DEBUG: Print cards for each variant
693
+ for v in variants:
694
+ cards = v.get('cards', [])
695
+ print(f"๐Ÿ” DEBUG: Variant '{v.get('name')}' has {len(cards)} cards: {cards}")
696
  return variants
697
  else:
698
  print("โš ๏ธ AI response invalid, using fallback")