Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,223 +1,174 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
**Culpa**:
|
119 |
-
- Siente remordimiento cuando toma un fin de semana libre mientras sus competidores siguen trabajando
|
120 |
-
- Se reprocha cuando invierte en un curso y no lo completa por falta de tiempo
|
121 |
-
- Experimenta culpa al delegar tareas y luego revisa obsesivamente el trabajo realizado
|
122 |
-
- Se siente mal cuando prioriza su bienestar sobre las demandas de clientes exigentes
|
123 |
-
- Se castiga mentalmente por no haber implementado antes estrategias que ahora ve funcionando en otros negocios
|
124 |
-
|
125 |
-
**Problemas**:
|
126 |
-
- Sufre episodios de insomnio pensando en pendientes y estrategias para el día siguiente
|
127 |
-
- Experimenta tensión en sus relaciones personales por su constante disponibilidad al trabajo
|
128 |
-
- Acumula tareas operativas que podría delegar pero no confía en que otros las hagan correctamente
|
129 |
-
- Posterga decisiones importantes sobre expansión por miedo a perder el control de la calidad
|
130 |
-
- Se resiste a implementar cambios tecnológicos necesarios por temor a desestabilizar lo que ya funciona
|
131 |
-
**Frustraciones**: Falta de progreso o crecimiento en su negocio o carrera, falta de reconocimiento o validación, desequilibrio entre su vida personal y profesional, falta de oportunidades para aprender y crecer, y falta de apoyo o colaboración. Le frustra cuando invierte tiempo y recursos en estrategias que no dan los resultados esperados.
|
132 |
-
|
133 |
-
**¿En qué está dispuesta a invertir?**: En ella misma y en su negocio, ya sea tomando cursos, contratando coaches o consultores, o adquiriendo nuevas herramientas y tecnologías que le permitan optimizar su tiempo y mejorar sus resultados. Valora especialmente las inversiones que ofrecen un retorno claro y medible.
|
134 |
-
|
135 |
-
**Intereses**: Mantenerse al día con las tendencias en su sector y adelantarse a la competencia. Le interesan los podcasts de negocios, libros de desarrollo personal, conferencias de emprendimiento y networking estratégico.
|
136 |
-
|
137 |
-
**Deseos**: Tener un impacto positivo en el mundo, ya sea a través de su negocio o actividades personales. Aspira a crear un legado que trascienda lo económico y genere un cambio significativo en su industria o comunidad.
|
138 |
-
|
139 |
-
**Lo que realmente quiere**: Lograr el éxito tanto en su vida personal como profesional para aumentar su potencial, vivir una vida llena de comodidades y lujos, ser respetada y admirada por sus habilidades y talentos, tener más tiempo para lo que ama y menos tiempo para lo que odia, ascender en la jerarquía social, y establecer relaciones cercanas y duraderas con amigos y familia. También busca validar sus sentimientos y demostrar que tiene razón a través de su éxito, escapar del peligro, y liberarse del miedo y la culpa que pueden impedirle alcanzar sus metas. Desea dejar un legado duradero y ser aceptada y apreciada por un grupo social o comunidad que comparta sus valores y aspiraciones.
|
140 |
-
|
141 |
-
---
|
142 |
-
**Validation Questions for Your Ideal Customer Profile:**
|
143 |
-
|
144 |
-
Have you addressed these essential aspects in your buyer persona?
|
145 |
-
|
146 |
-
1. **Demographics and Background:**
|
147 |
-
- Have you defined their age, gender, education level, and location?
|
148 |
-
- What is their current occupation and professional background?
|
149 |
-
- What is their socioeconomic status and lifestyle?
|
150 |
-
|
151 |
-
2. **Psychographics and Values:**
|
152 |
-
- What are their core values and beliefs?
|
153 |
-
- What aspirations drive their decisions?
|
154 |
-
- Which activities and interests align with your offering?
|
155 |
-
- How do their interests overlap with your expertise?
|
156 |
-
|
157 |
-
3. **Problems and Needs:**
|
158 |
-
- What specific problems are they trying to solve?
|
159 |
-
- Which pain points are most urgent for them?
|
160 |
-
- What frustrations are driving them to seek a solution?
|
161 |
-
- How does your solution address their specific challenges?
|
162 |
-
|
163 |
-
4. **Purchase Behavior:**
|
164 |
-
- What is their typical budget for similar solutions?
|
165 |
-
- How do they evaluate purchase decisions?
|
166 |
-
- What factors influence their buying choices?
|
167 |
-
- Are they willing to invest in premium solutions?
|
168 |
-
|
169 |
-
5. **Decision-Making Process:**
|
170 |
-
- Do they research thoroughly before buying?
|
171 |
-
- What information sources do they trust?
|
172 |
-
- How do reviews and recommendations influence them?
|
173 |
-
- What convinces them of a product's value?
|
174 |
-
|
175 |
-
Ensure your buyer persona thoroughly addresses these questions to create an accurate profile of someone who will value and invest in your offering.
|
176 |
-
---
|
177 |
-
|
178 |
-
This prompt ensures the ideal customer aligns with your interests and skills and will be a good prospect for your products/services."""
|
179 |
-
def create_instruction(product_service, skills, target_audience=None):
|
180 |
-
# Preparar la información del público objetivo si se proporciona
|
181 |
-
target_audience_info = ""
|
182 |
-
if target_audience:
|
183 |
-
target_audience_info = f"\n\nEl público objetivo específico es: {target_audience}. Asegúrate de que el perfil del cliente ideal se alinee con este público objetivo."
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dotenv import load_dotenv
|
2 |
+
import streamlit as st
|
3 |
+
import os
|
4 |
+
import google.generativeai as genai
|
5 |
+
from style import styles
|
6 |
+
from prompts import create_instruction
|
7 |
+
|
8 |
+
# Cargar las variables de entorno
|
9 |
+
load_dotenv()
|
10 |
+
|
11 |
+
# Configurar la API de Google
|
12 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
13 |
+
|
14 |
+
# Inicializar variables de estado en session_state si no existen
|
15 |
+
if 'perfil_cliente' not in st.session_state:
|
16 |
+
st.session_state.perfil_cliente = None
|
17 |
+
if 'producto' not in st.session_state:
|
18 |
+
st.session_state.producto = ""
|
19 |
+
if 'habilidades' not in st.session_state:
|
20 |
+
st.session_state.habilidades = ""
|
21 |
+
if 'creatividad' not in st.session_state:
|
22 |
+
st.session_state.creatividad = 1.0
|
23 |
+
|
24 |
+
# Función para generar el perfil de cliente ideal
|
25 |
+
@st.cache_resource
|
26 |
+
def get_model(temperature):
|
27 |
+
generation_config = {
|
28 |
+
"temperature": temperature,
|
29 |
+
}
|
30 |
+
return genai.GenerativeModel('gemini-2.0-flash', generation_config=generation_config)
|
31 |
+
|
32 |
+
def generate_buyer_persona(product, skills, target_audience, temperature):
|
33 |
+
if not product or not skills:
|
34 |
+
return "Por favor, completa los campos de producto y habilidades."
|
35 |
+
|
36 |
+
model = get_model(temperature)
|
37 |
+
instruction = create_instruction(
|
38 |
+
product_service=product,
|
39 |
+
skills=skills,
|
40 |
+
target_audience=target_audience
|
41 |
+
)
|
42 |
+
|
43 |
+
# Añadir instrucción explícita para respuesta en español
|
44 |
+
instruction += "\n\nIMPORTANTE: La respuesta debe estar completamente en español."
|
45 |
+
|
46 |
+
response = model.generate_content([instruction], generation_config={"temperature": temperature})
|
47 |
+
return response.parts[0].text if response and response.parts else "Error generando el perfil de cliente ideal."
|
48 |
+
|
49 |
+
# Modificar la función update_profile para que no use spinner
|
50 |
+
def update_profile():
|
51 |
+
# Solo actualizar la variable de sesión
|
52 |
+
st.session_state.submitted = True
|
53 |
+
|
54 |
+
# Configurar la interfaz de usuario con Streamlit
|
55 |
+
st.set_page_config(page_title="Generador de Cliente Ideal", page_icon="👤", layout="wide")
|
56 |
+
|
57 |
+
# Leer el contenido del archivo manual.md si existe
|
58 |
+
try:
|
59 |
+
with open("manual.md", "r", encoding="utf-8") as file:
|
60 |
+
manual_content = file.read()
|
61 |
+
# Mostrar el contenido del manual en el sidebar
|
62 |
+
st.sidebar.markdown(manual_content)
|
63 |
+
except FileNotFoundError:
|
64 |
+
st.sidebar.warning("Manual not found. Please create a manual.md file.")
|
65 |
+
except Exception as e:
|
66 |
+
st.sidebar.error(f"Error loading manual: {str(e)}")
|
67 |
+
|
68 |
+
# Ocultar elementos de la interfaz
|
69 |
+
st.markdown(styles["main_layout"], unsafe_allow_html=True)
|
70 |
+
|
71 |
+
# Centrar el título y el subtítulo
|
72 |
+
st.markdown("<h1 style='text-align: center;'>Generador de Perfil de Cliente Ideal</h1>", unsafe_allow_html=True)
|
73 |
+
st.markdown("<h4 style='text-align: center;'>Crea un perfil detallado de tu cliente ideal basado en tu producto y habilidades.</h4>", unsafe_allow_html=True)
|
74 |
+
|
75 |
+
# Añadir CSS personalizado para el botón
|
76 |
+
st.markdown(styles["button"], unsafe_allow_html=True)
|
77 |
+
# Añadir CSS personalizado para el botón de descarga
|
78 |
+
st.markdown(styles["download_button"], unsafe_allow_html=True)
|
79 |
+
|
80 |
+
# Crear columnas
|
81 |
+
col1, col2 = st.columns([1, 2])
|
82 |
+
|
83 |
+
# Columna de entrada
|
84 |
+
with col1:
|
85 |
+
producto = st.text_input("¿Qué producto o servicio ofreces?",
|
86 |
+
value=st.session_state.producto,
|
87 |
+
placeholder="Ejemplo: Curso de Inglés",
|
88 |
+
key="producto_input")
|
89 |
+
st.session_state.producto = producto
|
90 |
+
|
91 |
+
habilidades = st.text_input("¿Cuáles son tus habilidades principales?",
|
92 |
+
value=st.session_state.habilidades,
|
93 |
+
placeholder="Ejemplo: Enseñanza, comunicación, diseño de contenidos",
|
94 |
+
key="habilidades_input")
|
95 |
+
st.session_state.habilidades = habilidades
|
96 |
+
|
97 |
+
# Crear un acordeón para las opciones de personalización
|
98 |
+
with st.expander("Personaliza Tu Cliente Ideal Soñado"):
|
99 |
+
# Nuevo campo para público objetivo
|
100 |
+
if 'publico_objetivo' not in st.session_state:
|
101 |
+
st.session_state.publico_objetivo = ""
|
102 |
+
|
103 |
+
publico_objetivo = st.text_input("¿Cuál es tu público objetivo? (opcional)",
|
104 |
+
value=st.session_state.publico_objetivo,
|
105 |
+
placeholder="Ejemplo: Profesionales entre 25-40 años interesados en desarrollo personal",
|
106 |
+
key="publico_objetivo_input")
|
107 |
+
st.session_state.publico_objetivo = publico_objetivo
|
108 |
+
|
109 |
+
# Nivel de creatividad con slider
|
110 |
+
creatividad = st.slider("Nivel de creatividad",
|
111 |
+
min_value=0.0,
|
112 |
+
max_value=2.0,
|
113 |
+
value=st.session_state.creatividad,
|
114 |
+
step=0.1,
|
115 |
+
key="creatividad_slider")
|
116 |
+
st.session_state.creatividad = creatividad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
+
# Botón para generar
|
119 |
+
submit = st.button("GENERAR PERFIL DE CLIENTE IDEAL", on_click=update_profile)
|
120 |
+
|
121 |
+
# Columna de resultados
|
122 |
+
with col2:
|
123 |
+
# Verificar si se ha enviado el formulario
|
124 |
+
if 'submitted' in st.session_state and st.session_state.submitted:
|
125 |
+
if st.session_state.producto and st.session_state.habilidades:
|
126 |
+
with st.spinner("Creando tu Cliente Ideal Soñado..."):
|
127 |
+
# Generar el perfil del cliente
|
128 |
+
perfil_cliente = generate_buyer_persona(
|
129 |
+
st.session_state.producto,
|
130 |
+
st.session_state.habilidades,
|
131 |
+
st.session_state.publico_objetivo,
|
132 |
+
st.session_state.creatividad
|
133 |
+
)
|
134 |
+
# Guardar en session_state
|
135 |
+
st.session_state.perfil_cliente = perfil_cliente
|
136 |
+
# Resetear el estado de envío
|
137 |
+
st.session_state.submitted = False
|
138 |
+
|
139 |
+
# Mostrar resultados
|
140 |
+
if not isinstance(st.session_state.perfil_cliente, str):
|
141 |
+
st.error("Error al generar el perfil de cliente ideal")
|
142 |
+
else:
|
143 |
+
st.markdown(f"""
|
144 |
+
<div style="{styles['results_container']}">
|
145 |
+
<h3>Tu Cliente Ideal</h3>
|
146 |
+
{st.session_state.perfil_cliente}
|
147 |
+
</div>
|
148 |
+
""", unsafe_allow_html=True)
|
149 |
+
|
150 |
+
# Opción para descargar
|
151 |
+
st.download_button(
|
152 |
+
label="Descargar Perfil",
|
153 |
+
data=st.session_state.perfil_cliente,
|
154 |
+
file_name="cliente_ideal.md",
|
155 |
+
mime="text/markdown"
|
156 |
+
)
|
157 |
+
else:
|
158 |
+
st.warning("Por favor, completa los campos de producto y habilidades antes de generar el perfil.")
|
159 |
+
# Mostrar resultados anteriores si existen
|
160 |
+
elif st.session_state.perfil_cliente:
|
161 |
+
st.markdown(f"""
|
162 |
+
<div style="{styles['results_container']}">
|
163 |
+
<h3>Tu Cliente Ideal</h3>
|
164 |
+
{st.session_state.perfil_cliente}
|
165 |
+
</div>
|
166 |
+
""", unsafe_allow_html=True)
|
167 |
+
|
168 |
+
# Opción para descargar
|
169 |
+
st.download_button(
|
170 |
+
label="Descargar Perfil",
|
171 |
+
data=st.session_state.perfil_cliente,
|
172 |
+
file_name="cliente_ideal.md",
|
173 |
+
mime="text/markdown"
|
174 |
+
)
|