Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,124 +1,126 @@
|
|
| 1 |
-
from dotenv import load_dotenv
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import os
|
| 4 |
-
import google.generativeai as genai
|
| 5 |
-
from puv_formulas import puv_formulas
|
| 6 |
-
from styles import apply_styles
|
| 7 |
-
|
| 8 |
-
# Cargar variables de entorno
|
| 9 |
-
load_dotenv()
|
| 10 |
-
|
| 11 |
-
# Configurar API de Google Gemini
|
| 12 |
-
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 13 |
-
|
| 14 |
-
# Funci贸n para obtener la respuesta del modelo Gemini
|
| 15 |
-
def get_gemini_response(product_service, target_audience, formula_type, temperature):
|
| 16 |
-
if not product_service or not target_audience:
|
| 17 |
-
return "Please complete all required fields."
|
| 18 |
-
|
| 19 |
-
formula = puv_formulas[formula_type]
|
| 20 |
-
|
| 21 |
-
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 22 |
-
full_prompt = f"""
|
| 23 |
-
You are a UVP (Unique Value Proposition) expert. Analyze the following information and create THREE compelling UVPs:
|
| 24 |
-
|
| 25 |
-
BUSINESS INFORMATION:
|
| 26 |
-
Product/Service: {product_service}
|
| 27 |
-
Target Audience: {target_audience}
|
| 28 |
-
Formula Type: {formula_type}
|
| 29 |
-
|
| 30 |
-
{formula["description"]}
|
| 31 |
-
|
| 32 |
-
First, analyze and provide:
|
| 33 |
-
1. TARGET AUDIENCE ANALYSIS - Pain Points:
|
| 34 |
-
- What specific frustrations does this audience experience?
|
| 35 |
-
- What are their biggest daily challenges?
|
| 36 |
-
- What emotional problems do they face?
|
| 37 |
-
- What have they tried before that didn't work?
|
| 38 |
-
- What's stopping them from achieving their goals?
|
| 39 |
-
|
| 40 |
-
2. PRODUCT/SERVICE ANALYSIS - Benefits:
|
| 41 |
-
- What tangible results do clients get?
|
| 42 |
-
- What specific transformation does it offer?
|
| 43 |
-
- What's the unique method or differentiator?
|
| 44 |
-
- What competitive advantages does it have?
|
| 45 |
-
- What emotional benefits does it provide?
|
| 46 |
-
|
| 47 |
-
Then, create THREE different UVPs following the formula structure provided above.
|
| 48 |
-
|
| 49 |
-
CRITICAL INSTRUCTIONS:
|
| 50 |
-
- Each UVP must be specific and measurable
|
| 51 |
-
- Focus on the transformation journey
|
| 52 |
-
- Use natural, conversational language
|
| 53 |
-
- Avoid generic phrases and buzzwords
|
| 54 |
-
- Maximum 2 lines per UVP
|
| 55 |
-
- Separate sections with "---"
|
| 56 |
-
|
| 57 |
-
Format your response as:
|
| 58 |
-
TARGET AUDIENCE ANALYSIS (Pain Points)
|
| 59 |
-
[Detailed target audience analysis]
|
| 60 |
-
---
|
| 61 |
-
PRODUCT/SERVICE ANALYSIS (Benefits)
|
| 62 |
-
[Detailed product/service benefits]
|
| 63 |
-
---
|
| 64 |
-
VALUE PROPOSITIONS:
|
| 65 |
-
[Three UVPs]
|
| 66 |
-
"""
|
| 67 |
-
|
| 68 |
-
response = model.generate_content([full_prompt], generation_config={"temperature": temperature})
|
| 69 |
-
return response.parts[0].text if response and response.parts else "Error generating content."
|
| 70 |
-
|
| 71 |
-
# Configurar la aplicaci贸n Streamlit
|
| 72 |
-
st.set_page_config(page_title="UVP Generator", page_icon="馃挕", layout="wide")
|
| 73 |
-
|
| 74 |
-
# T铆tulo de la app
|
| 75 |
-
st.markdown("<h1>UVP Generator</h1>", unsafe_allow_html=True)
|
| 76 |
-
st.markdown("<h3>Create powerful Unique Value Propositions that attract your ideal clients and communicate your unique value.</h3>", unsafe_allow_html=True)
|
| 77 |
-
|
| 78 |
-
# Sidebar manual
|
| 79 |
-
with open("manual.md", "r", encoding="utf-8") as file:
|
| 80 |
-
manual_content = file.read()
|
| 81 |
-
st.sidebar.markdown(manual_content)
|
| 82 |
-
|
| 83 |
-
# Crear dos columnas
|
| 84 |
-
col1, col2 = st.columns([1, 1])
|
| 85 |
-
|
| 86 |
-
# Columna izquierda para inputs
|
| 87 |
-
with col1:
|
| 88 |
-
product_service = st.text_area(
|
| 89 |
-
"What's your product or service?",
|
| 90 |
-
placeholder="Example: AI-powered copywriting course, Coaching program..."
|
| 91 |
-
)
|
| 92 |
-
|
| 93 |
-
target_audience = st.text_area(
|
| 94 |
-
"Who's your target audience?",
|
| 95 |
-
placeholder="Example: Coaches who want to attract more clients..."
|
| 96 |
-
)
|
| 97 |
-
with st.expander("Advanced options"):
|
| 98 |
-
formula_type = st.selectbox(
|
| 99 |
-
"UVP Formula:",
|
| 100 |
-
options=list(puv_formulas.keys())
|
| 101 |
-
)
|
| 102 |
-
temperature = st.slider(
|
| 103 |
-
"Creativity level:",
|
| 104 |
-
min_value=0.0,
|
| 105 |
-
max_value=2.0,
|
| 106 |
-
value=1.0,
|
| 107 |
-
step=0.1,
|
| 108 |
-
help="Higher values generate more creative but less predictable propositions."
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
generate_button = st.button("Generate UVP")
|
| 112 |
-
|
| 113 |
-
with col2:
|
| 114 |
-
if generate_button:
|
| 115 |
-
response = get_gemini_response(
|
| 116 |
-
product_service,
|
| 117 |
-
target_audience,
|
| 118 |
-
formula_type,
|
| 119 |
-
temperature
|
| 120 |
-
)
|
| 121 |
-
sections = response.split("---")
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import os
|
| 4 |
+
import google.generativeai as genai
|
| 5 |
+
from puv_formulas import puv_formulas
|
| 6 |
+
from styles import apply_styles
|
| 7 |
+
|
| 8 |
+
# Cargar variables de entorno
|
| 9 |
+
load_dotenv()
|
| 10 |
+
|
| 11 |
+
# Configurar API de Google Gemini
|
| 12 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 13 |
+
|
| 14 |
+
# Funci贸n para obtener la respuesta del modelo Gemini
|
| 15 |
+
def get_gemini_response(product_service, target_audience, formula_type, temperature):
|
| 16 |
+
if not product_service or not target_audience:
|
| 17 |
+
return "Please complete all required fields."
|
| 18 |
+
|
| 19 |
+
formula = puv_formulas[formula_type]
|
| 20 |
+
|
| 21 |
+
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 22 |
+
full_prompt = f"""
|
| 23 |
+
You are a UVP (Unique Value Proposition) expert. Analyze the following information and create THREE compelling UVPs:
|
| 24 |
+
|
| 25 |
+
BUSINESS INFORMATION:
|
| 26 |
+
Product/Service: {product_service}
|
| 27 |
+
Target Audience: {target_audience}
|
| 28 |
+
Formula Type: {formula_type}
|
| 29 |
+
|
| 30 |
+
{formula["description"]}
|
| 31 |
+
|
| 32 |
+
First, analyze and provide:
|
| 33 |
+
1. TARGET AUDIENCE ANALYSIS - Pain Points:
|
| 34 |
+
- What specific frustrations does this audience experience?
|
| 35 |
+
- What are their biggest daily challenges?
|
| 36 |
+
- What emotional problems do they face?
|
| 37 |
+
- What have they tried before that didn't work?
|
| 38 |
+
- What's stopping them from achieving their goals?
|
| 39 |
+
|
| 40 |
+
2. PRODUCT/SERVICE ANALYSIS - Benefits:
|
| 41 |
+
- What tangible results do clients get?
|
| 42 |
+
- What specific transformation does it offer?
|
| 43 |
+
- What's the unique method or differentiator?
|
| 44 |
+
- What competitive advantages does it have?
|
| 45 |
+
- What emotional benefits does it provide?
|
| 46 |
+
|
| 47 |
+
Then, create THREE different UVPs following the formula structure provided above.
|
| 48 |
+
|
| 49 |
+
CRITICAL INSTRUCTIONS:
|
| 50 |
+
- Each UVP must be specific and measurable
|
| 51 |
+
- Focus on the transformation journey
|
| 52 |
+
- Use natural, conversational language
|
| 53 |
+
- Avoid generic phrases and buzzwords
|
| 54 |
+
- Maximum 2 lines per UVP
|
| 55 |
+
- Separate sections with "---"
|
| 56 |
+
|
| 57 |
+
Format your response as:
|
| 58 |
+
TARGET AUDIENCE ANALYSIS (Pain Points)
|
| 59 |
+
[Detailed target audience analysis]
|
| 60 |
+
---
|
| 61 |
+
PRODUCT/SERVICE ANALYSIS (Benefits)
|
| 62 |
+
[Detailed product/service benefits]
|
| 63 |
+
---
|
| 64 |
+
VALUE PROPOSITIONS:
|
| 65 |
+
[Three UVPs]
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
response = model.generate_content([full_prompt], generation_config={"temperature": temperature})
|
| 69 |
+
return response.parts[0].text if response and response.parts else "Error generating content."
|
| 70 |
+
|
| 71 |
+
# Configurar la aplicaci贸n Streamlit
|
| 72 |
+
st.set_page_config(page_title="UVP Generator", page_icon="馃挕", layout="wide")
|
| 73 |
+
|
| 74 |
+
# T铆tulo de la app
|
| 75 |
+
st.markdown("<h1>UVP Generator</h1>", unsafe_allow_html=True)
|
| 76 |
+
st.markdown("<h3>Create powerful Unique Value Propositions that attract your ideal clients and communicate your unique value.</h3>", unsafe_allow_html=True)
|
| 77 |
+
|
| 78 |
+
# Sidebar manual
|
| 79 |
+
with open("manual.md", "r", encoding="utf-8") as file:
|
| 80 |
+
manual_content = file.read()
|
| 81 |
+
st.sidebar.markdown(manual_content)
|
| 82 |
+
|
| 83 |
+
# Crear dos columnas
|
| 84 |
+
col1, col2 = st.columns([1, 1])
|
| 85 |
+
|
| 86 |
+
# Columna izquierda para inputs
|
| 87 |
+
with col1:
|
| 88 |
+
product_service = st.text_area(
|
| 89 |
+
"What's your product or service?",
|
| 90 |
+
placeholder="Example: AI-powered copywriting course, Coaching program..."
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
target_audience = st.text_area(
|
| 94 |
+
"Who's your target audience?",
|
| 95 |
+
placeholder="Example: Coaches who want to attract more clients..."
|
| 96 |
+
)
|
| 97 |
+
with st.expander("Advanced options"):
|
| 98 |
+
formula_type = st.selectbox(
|
| 99 |
+
"UVP Formula:",
|
| 100 |
+
options=list(puv_formulas.keys())
|
| 101 |
+
)
|
| 102 |
+
temperature = st.slider(
|
| 103 |
+
"Creativity level:",
|
| 104 |
+
min_value=0.0,
|
| 105 |
+
max_value=2.0,
|
| 106 |
+
value=1.0,
|
| 107 |
+
step=0.1,
|
| 108 |
+
help="Higher values generate more creative but less predictable propositions."
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
generate_button = st.button("Generate UVP")
|
| 112 |
+
|
| 113 |
+
with col2:
|
| 114 |
+
if generate_button:
|
| 115 |
+
response = get_gemini_response(
|
| 116 |
+
product_service,
|
| 117 |
+
target_audience,
|
| 118 |
+
formula_type,
|
| 119 |
+
temperature
|
| 120 |
+
)
|
| 121 |
+
sections = response.split("---")
|
| 122 |
+
# Solo mostrar la 煤ltima secci贸n que contiene las UVPs
|
| 123 |
+
uvps = sections[-1].strip() # La 煤ltima secci贸n contiene las UVPs
|
| 124 |
+
if "VALUE PROPOSITIONS:" in uvps:
|
| 125 |
+
uvps = uvps.replace("VALUE PROPOSITIONS:", "").strip()
|
| 126 |
+
st.write(uvps)
|