Spaces:
Sleeping
Sleeping
Claude commited on
Commit ·
a740077
1
Parent(s): fe97795
Add custom prompt field to AC3 for user-defined screen generation
Browse files- agents/flutter_screen_generator.py +9 -3
- app.py +10 -1
agents/flutter_screen_generator.py
CHANGED
|
@@ -406,6 +406,7 @@ class FlutterScreenGenerator:
|
|
| 406 |
theme = input_data.get("theme", {})
|
| 407 |
app_type = input_data.get("app_type", "generic")
|
| 408 |
screen_types = input_data.get("screens", ["home"])
|
|
|
|
| 409 |
|
| 410 |
# GENERA SOLO 1 SCHERMATA (sempre home)
|
| 411 |
screen_type = "home"
|
|
@@ -415,7 +416,7 @@ class FlutterScreenGenerator:
|
|
| 415 |
print(f"🤖 AI generating 4 intelligent variants for {app_type}...")
|
| 416 |
|
| 417 |
if self.deepseek_api_key:
|
| 418 |
-
variants = self._generate_variants_with_ai(theme, app_type)
|
| 419 |
else:
|
| 420 |
print("⚠️ No DEEPSEEK_API_KEY - using fallback variants")
|
| 421 |
variants = self._get_fallback_variants(app_type)
|
|
@@ -580,7 +581,7 @@ JSON Plan:"""
|
|
| 580 |
|
| 581 |
return prompt
|
| 582 |
|
| 583 |
-
def _generate_variants_with_ai(self, theme: Dict[str, Any], app_type: str) -> list:
|
| 584 |
"""
|
| 585 |
Use DeepSeek Coder to generate 4 intelligent UI variants
|
| 586 |
Each variant combines background + header + footer appropriately
|
|
@@ -608,7 +609,12 @@ JSON Plan:"""
|
|
| 608 |
cards_list = card_suggestions.get(app_type, card_suggestions["generic"])
|
| 609 |
cards_str = ", ".join(cards_list)
|
| 610 |
|
| 611 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
|
| 613 |
PALETTE:
|
| 614 |
- Primary: {theme_summary['primary']}
|
|
|
|
| 406 |
theme = input_data.get("theme", {})
|
| 407 |
app_type = input_data.get("app_type", "generic")
|
| 408 |
screen_types = input_data.get("screens", ["home"])
|
| 409 |
+
custom_prompt = input_data.get("custom_prompt", "") # Get custom prompt
|
| 410 |
|
| 411 |
# GENERA SOLO 1 SCHERMATA (sempre home)
|
| 412 |
screen_type = "home"
|
|
|
|
| 416 |
print(f"🤖 AI generating 4 intelligent variants for {app_type}...")
|
| 417 |
|
| 418 |
if self.deepseek_api_key:
|
| 419 |
+
variants = self._generate_variants_with_ai(theme, app_type, custom_prompt)
|
| 420 |
else:
|
| 421 |
print("⚠️ No DEEPSEEK_API_KEY - using fallback variants")
|
| 422 |
variants = self._get_fallback_variants(app_type)
|
|
|
|
| 581 |
|
| 582 |
return prompt
|
| 583 |
|
| 584 |
+
def _generate_variants_with_ai(self, theme: Dict[str, Any], app_type: str, custom_prompt: str = "") -> list:
|
| 585 |
"""
|
| 586 |
Use DeepSeek Coder to generate 4 intelligent UI variants
|
| 587 |
Each variant combines background + header + footer appropriately
|
|
|
|
| 609 |
cards_list = card_suggestions.get(app_type, card_suggestions["generic"])
|
| 610 |
cards_str = ", ".join(cards_list)
|
| 611 |
|
| 612 |
+
# Use custom prompt if provided, otherwise use default
|
| 613 |
+
task_description = custom_prompt if custom_prompt.strip() else f"Genera UNA home page per l'app {app_type}"
|
| 614 |
+
print(f"📝 Using prompt: {task_description}")
|
| 615 |
+
|
| 616 |
+
prompt = f"""{task_description}
|
| 617 |
+
Crea 4 VERSIONI DIVERSE della schermata richiesta.
|
| 618 |
|
| 619 |
PALETTE:
|
| 620 |
- Primary: {theme_summary['primary']}
|
app.py
CHANGED
|
@@ -774,6 +774,7 @@ def generate_design_themes(
|
|
| 774 |
def generate_flutter_screens(
|
| 775 |
theme_json: str,
|
| 776 |
app_type: str,
|
|
|
|
| 777 |
screens_text: str
|
| 778 |
):
|
| 779 |
"""
|
|
@@ -808,6 +809,7 @@ def generate_flutter_screens(
|
|
| 808 |
input_data = {
|
| 809 |
"theme": theme,
|
| 810 |
"app_type": app_type,
|
|
|
|
| 811 |
"screens": screens[:3] # Max 3 screens
|
| 812 |
}
|
| 813 |
|
|
@@ -4471,6 +4473,13 @@ Snapchat - bright colors, fun filters, youthful design""",
|
|
| 4471 |
value="fitness"
|
| 4472 |
)
|
| 4473 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4474 |
screens_input = gr.Textbox(
|
| 4475 |
label="Screens (comma-separated, max 3)",
|
| 4476 |
placeholder="home, detail, profile",
|
|
@@ -4646,7 +4655,7 @@ Snapchat - bright colors, fun filters, youthful design""",
|
|
| 4646 |
# Connect button
|
| 4647 |
generate_flutter_btn.click(
|
| 4648 |
fn=generate_flutter_screens,
|
| 4649 |
-
inputs=[theme_json_input, app_type_dropdown, screens_input],
|
| 4650 |
outputs=[
|
| 4651 |
summary_output,
|
| 4652 |
preview_waves, code_waves,
|
|
|
|
| 774 |
def generate_flutter_screens(
|
| 775 |
theme_json: str,
|
| 776 |
app_type: str,
|
| 777 |
+
custom_prompt: str,
|
| 778 |
screens_text: str
|
| 779 |
):
|
| 780 |
"""
|
|
|
|
| 809 |
input_data = {
|
| 810 |
"theme": theme,
|
| 811 |
"app_type": app_type,
|
| 812 |
+
"custom_prompt": custom_prompt, # Add custom prompt
|
| 813 |
"screens": screens[:3] # Max 3 screens
|
| 814 |
}
|
| 815 |
|
|
|
|
| 4473 |
value="fitness"
|
| 4474 |
)
|
| 4475 |
|
| 4476 |
+
custom_prompt = gr.Textbox(
|
| 4477 |
+
label="📝 Prompt Personalizzato (cosa vuoi generare)",
|
| 4478 |
+
placeholder="Esempio: Genera una home page per app fitness con statistiche, Crea una schermata login moderna, etc.",
|
| 4479 |
+
lines=3,
|
| 4480 |
+
value="Genera una home page per l'app con cards, header e footer"
|
| 4481 |
+
)
|
| 4482 |
+
|
| 4483 |
screens_input = gr.Textbox(
|
| 4484 |
label="Screens (comma-separated, max 3)",
|
| 4485 |
placeholder="home, detail, profile",
|
|
|
|
| 4655 |
# Connect button
|
| 4656 |
generate_flutter_btn.click(
|
| 4657 |
fn=generate_flutter_screens,
|
| 4658 |
+
inputs=[theme_json_input, app_type_dropdown, custom_prompt, screens_input],
|
| 4659 |
outputs=[
|
| 4660 |
summary_output,
|
| 4661 |
preview_waves, code_waves,
|