JeCabrera's picture
Upload 4 files
e7e4eca verified
raw
history blame
4.51 kB
from dotenv import load_dotenv
import streamlit as st
import os
import google.generativeai as genai
from puv_formulas import puv_formulas
from styles import apply_styles
# Cargar variables de entorno
load_dotenv()
# Configurar API de Google Gemini
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# Función para obtener la respuesta del modelo Gemini
def get_gemini_response(product_service, target_audience, formula_type, temperature):
if not product_service or not target_audience:
return "Please complete all required fields."
formula = puv_formulas[formula_type]
model = genai.GenerativeModel('gemini-2.0-flash')
full_prompt = f"""
You are a UVP (Unique Value Proposition) expert. Analyze (internally only, do not output the analysis) the following information:
BUSINESS INFORMATION:
Product/Service: {product_service}
Target Audience: {target_audience}
Formula Type: {formula_type}
{formula["description"]}
EXAMPLE TO FOLLOW:
{formula["examples"]}
First, analyze (but don't output) these points:
1. TARGET AUDIENCE ANALYSIS - Pain Points:
- What specific frustrations does this audience experience?
- What are their biggest daily challenges?
- What emotional problems do they face?
- What have they tried before that didn't work?
- What's stopping them from achieving their goals?
2. PRODUCT/SERVICE ANALYSIS - Benefits:
- What tangible results do clients get?
- What specific transformation does it offer?
- What's the unique method or differentiator?
- What competitive advantages does it have?
- What emotional benefits does it provide?
Based on your internal analysis of the target audience pain points and product benefits (do not include this analysis in the output), create THREE different UVPs in Spanish language following the formula structure provided.
CRITICAL INSTRUCTIONS:
- Each UVP must be specific and measurable
- Focus on the transformation journey
- Use natural, conversational language
- Avoid generic phrases and buzzwords
- Maximum 2 lines per UVP
- DO NOT include any analysis in the output
- ONLY output the three UVPs
Output EXACTLY in this format (no additional text) in Spanish language:
1. [First UVP]
2. [Second UVP]
3. [Third UVP]
"""
response = model.generate_content([full_prompt], generation_config={"temperature": temperature})
return response.parts[0].text if response and response.parts else "Error generating content."
# Configurar la aplicación Streamlit
st.set_page_config(page_title="UVP Generator", page_icon="💡", layout="wide")
# Aplicar estilos
st.markdown(apply_styles(), unsafe_allow_html=True)
# Título de la app
st.markdown("<h1>Generador de PUV</h1>", unsafe_allow_html=True)
st.markdown("<h3>Crea Propuestas Únicas de Valor poderosas que atraigan a tus clientes ideales y comuniquen tu valor de manera efectiva.</h3>", unsafe_allow_html=True)
# Sidebar manual
with open("manual.md", "r", encoding="utf-8") as file:
manual_content = file.read()
st.sidebar.markdown(manual_content)
# Crear dos columnas
col1, col2 = st.columns([1, 1])
# Columna izquierda para inputs
with col1:
target_audience = st.text_area(
"¿Cuál es tu público objetivo?",
placeholder="Ejemplo: Coaches que quieren atraer más clientes..."
)
product_service = st.text_area(
"¿Cuál es tu producto o servicio?",
placeholder="Ejemplo: Curso de copywriting con IA, Programa de coaching..."
)
with st.expander("Opciones avanzadas"):
formula_type = st.selectbox(
"Fórmula PUV:",
options=list(puv_formulas.keys())
)
temperature = st.slider(
"Nivel de creatividad:",
min_value=0.0,
max_value=2.0,
value=1.0,
step=0.1,
help="Valores más altos generan propuestas más creativas pero menos predecibles."
)
generate_button = st.button("Generar PUV")
with col2:
if generate_button:
response = get_gemini_response(
product_service,
target_audience,
formula_type,
temperature
)
st.write("### Propuestas Únicas de Valor")
st.write(response)