Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from crewai import Agent, Task, Crew, Process, LLM
|
| 4 |
-
from crewai_tools import
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import traceback
|
| 7 |
|
|
@@ -11,7 +11,7 @@ load_dotenv()
|
|
| 11 |
try:
|
| 12 |
# Use CrewAI's LLM class with proper format for Gemini
|
| 13 |
llm = LLM(
|
| 14 |
-
model="gemini/gemini-
|
| 15 |
temperature=0.6,
|
| 16 |
api_key=os.environ.get("GOOGLE_API_KEY")
|
| 17 |
)
|
|
@@ -23,9 +23,6 @@ except Exception as e:
|
|
| 23 |
llm = None
|
| 24 |
|
| 25 |
# --- 2. DEFINE TOOLS AND OUTPUT DIRECTORY ---
|
| 26 |
-
# Using SerperDevTool for web search (you'll need SERPER_API_KEY in your environment)
|
| 27 |
-
# Alternatively, you can remove the search tool if you don't have the API key
|
| 28 |
-
search_tool = SerperDevTool()
|
| 29 |
os.makedirs("outputs", exist_ok=True)
|
| 30 |
file_write_tool = FileWriterTool()
|
| 31 |
|
|
@@ -34,19 +31,20 @@ designer = Agent(
|
|
| 34 |
role='Principal Brand Designer',
|
| 35 |
goal='Translate a user\'s "vibe" into a concrete, professional design brief for a website.',
|
| 36 |
backstory=(
|
| 37 |
-
"You are a world-class brand designer with a keen eye for aesthetics. "
|
| 38 |
-
"You excel at understanding abstract concepts and turning them into actionable design elements."
|
|
|
|
| 39 |
),
|
| 40 |
verbose=True,
|
| 41 |
llm=llm,
|
| 42 |
-
tools=[search_tool],
|
| 43 |
allow_delegation=False
|
| 44 |
)
|
| 45 |
copywriter = Agent(
|
| 46 |
role='Senior UX Copywriter',
|
| 47 |
goal='Write compelling, vibe-appropriate copy for all sections of a website based on a design brief.',
|
| 48 |
backstory=(
|
| 49 |
-
"You are an expert copywriter who specializes in creating website content that resonates with the target audience."
|
|
|
|
| 50 |
),
|
| 51 |
verbose=True,
|
| 52 |
llm=llm,
|
|
@@ -56,7 +54,8 @@ developer = Agent(
|
|
| 56 |
role='Senior Frontend Developer',
|
| 57 |
goal='Take a design brief and content map to build a complete, self-contained HTML file.',
|
| 58 |
backstory=(
|
| 59 |
-
"You are a skilled frontend developer who can build beautiful and functional websites from scratch."
|
|
|
|
| 60 |
),
|
| 61 |
verbose=True,
|
| 62 |
llm=llm,
|
|
@@ -68,33 +67,53 @@ developer = Agent(
|
|
| 68 |
design_task = Task(
|
| 69 |
description=(
|
| 70 |
"Analyze the user's prompt: '{prompt}' to understand the desired vibe. "
|
| 71 |
-
"
|
| 72 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
),
|
| 74 |
expected_output=(
|
| 75 |
-
"A structured markdown document with the complete Design Brief
|
|
|
|
| 76 |
),
|
| 77 |
agent=designer
|
| 78 |
)
|
| 79 |
copywriting_task = Task(
|
| 80 |
description=(
|
| 81 |
"Using the Design Brief, write all text content for the website. "
|
| 82 |
-
"Ensure the tone
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
),
|
| 84 |
expected_output=(
|
| 85 |
-
"A structured markdown 'Content Map' with text for each section of the website."
|
| 86 |
),
|
| 87 |
agent=copywriter,
|
| 88 |
context=[design_task]
|
| 89 |
)
|
| 90 |
development_task = Task(
|
| 91 |
description=(
|
| 92 |
-
"Based on the Design Brief and Content Map, create a single-file HTML website. "
|
| 93 |
-
"
|
| 94 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
),
|
| 96 |
expected_output=(
|
| 97 |
-
"
|
| 98 |
),
|
| 99 |
agent=developer,
|
| 100 |
context=[design_task, copywriting_task],
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from crewai import Agent, Task, Crew, Process, LLM
|
| 4 |
+
from crewai_tools import FileWriterTool
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import traceback
|
| 7 |
|
|
|
|
| 11 |
try:
|
| 12 |
# Use CrewAI's LLM class with proper format for Gemini
|
| 13 |
llm = LLM(
|
| 14 |
+
model="gemini/gemini-1.5-flash",
|
| 15 |
temperature=0.6,
|
| 16 |
api_key=os.environ.get("GOOGLE_API_KEY")
|
| 17 |
)
|
|
|
|
| 23 |
llm = None
|
| 24 |
|
| 25 |
# --- 2. DEFINE TOOLS AND OUTPUT DIRECTORY ---
|
|
|
|
|
|
|
|
|
|
| 26 |
os.makedirs("outputs", exist_ok=True)
|
| 27 |
file_write_tool = FileWriterTool()
|
| 28 |
|
|
|
|
| 31 |
role='Principal Brand Designer',
|
| 32 |
goal='Translate a user\'s "vibe" into a concrete, professional design brief for a website.',
|
| 33 |
backstory=(
|
| 34 |
+
"You are a world-class brand designer with a keen eye for aesthetics and deep knowledge of design trends. "
|
| 35 |
+
"You excel at understanding abstract concepts and turning them into actionable design elements. "
|
| 36 |
+
"You have extensive knowledge of color theory, typography, and modern web design best practices."
|
| 37 |
),
|
| 38 |
verbose=True,
|
| 39 |
llm=llm,
|
|
|
|
| 40 |
allow_delegation=False
|
| 41 |
)
|
| 42 |
copywriter = Agent(
|
| 43 |
role='Senior UX Copywriter',
|
| 44 |
goal='Write compelling, vibe-appropriate copy for all sections of a website based on a design brief.',
|
| 45 |
backstory=(
|
| 46 |
+
"You are an expert copywriter who specializes in creating website content that resonates with the target audience. "
|
| 47 |
+
"You understand how to match tone and style to brand identity."
|
| 48 |
),
|
| 49 |
verbose=True,
|
| 50 |
llm=llm,
|
|
|
|
| 54 |
role='Senior Frontend Developer',
|
| 55 |
goal='Take a design brief and content map to build a complete, self-contained HTML file.',
|
| 56 |
backstory=(
|
| 57 |
+
"You are a skilled frontend developer who can build beautiful and functional websites from scratch. "
|
| 58 |
+
"You are expert in HTML5, CSS3, responsive design, and creating visually stunning web experiences."
|
| 59 |
),
|
| 60 |
verbose=True,
|
| 61 |
llm=llm,
|
|
|
|
| 67 |
design_task = Task(
|
| 68 |
description=(
|
| 69 |
"Analyze the user's prompt: '{prompt}' to understand the desired vibe. "
|
| 70 |
+
"Using your extensive design knowledge, create a comprehensive 'Design Brief' document that includes:\n"
|
| 71 |
+
"1. A carefully selected color palette with 3-5 colors (provide hex codes)\n"
|
| 72 |
+
"2. Font pairing recommendations using Google Fonts (specify primary and secondary fonts)\n"
|
| 73 |
+
"3. Overall aesthetic direction (modern, minimalist, bold, etc.)\n"
|
| 74 |
+
"4. Detailed page structure with sections (hero, about, portfolio/services, contact, etc.)\n"
|
| 75 |
+
"5. Design principles to follow (spacing, imagery style, etc.)"
|
| 76 |
),
|
| 77 |
expected_output=(
|
| 78 |
+
"A structured markdown document with the complete Design Brief including Color Palette (with hex codes), "
|
| 79 |
+
"Font Pairing (Google Fonts names), Aesthetic Direction, Page Structure, and Design Principles."
|
| 80 |
),
|
| 81 |
agent=designer
|
| 82 |
)
|
| 83 |
copywriting_task = Task(
|
| 84 |
description=(
|
| 85 |
"Using the Design Brief, write all text content for the website. "
|
| 86 |
+
"Ensure the tone and style match the specified vibe perfectly. "
|
| 87 |
+
"Create engaging, professional copy for each section including:\n"
|
| 88 |
+
"- Hero section headline and subheadline\n"
|
| 89 |
+
"- About section text\n"
|
| 90 |
+
"- Service/Portfolio descriptions\n"
|
| 91 |
+
"- Call-to-action text\n"
|
| 92 |
+
"- Contact section copy\n"
|
| 93 |
+
"Make the content authentic and compelling."
|
| 94 |
),
|
| 95 |
expected_output=(
|
| 96 |
+
"A structured markdown 'Content Map' with polished, ready-to-use text for each section of the website."
|
| 97 |
),
|
| 98 |
agent=copywriter,
|
| 99 |
context=[design_task]
|
| 100 |
)
|
| 101 |
development_task = Task(
|
| 102 |
description=(
|
| 103 |
+
"Based on the Design Brief and Content Map, create a complete, production-ready, single-file HTML website. "
|
| 104 |
+
"Requirements:\n"
|
| 105 |
+
"- Self-contained HTML file with embedded CSS (in <style> tags)\n"
|
| 106 |
+
"- Use the exact colors from the design brief (hex codes)\n"
|
| 107 |
+
"- Import and use the specified Google Fonts\n"
|
| 108 |
+
"- Fully responsive design that works on mobile, tablet, and desktop\n"
|
| 109 |
+
"- Modern, clean code with proper semantic HTML5\n"
|
| 110 |
+
"- Include smooth scrolling and subtle animations where appropriate\n"
|
| 111 |
+
"- Use the content from the Content Map\n"
|
| 112 |
+
"- Save the complete HTML to 'outputs/index.html' using the FileWriterTool\n\n"
|
| 113 |
+
"The file path for FileWriterTool should be: outputs/index.html"
|
| 114 |
),
|
| 115 |
expected_output=(
|
| 116 |
+
"A complete, functional HTML website file saved to 'outputs/index.html'."
|
| 117 |
),
|
| 118 |
agent=developer,
|
| 119 |
context=[design_task, copywriting_task],
|