Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,8 @@ from dotenv import load_dotenv
|
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import google.generativeai as genai
|
5 |
-
from bullet_formulas import bullet_formulas
|
6 |
from style import styles
|
7 |
from prompts import create_instruction
|
8 |
-
from angles import bullet_angles
|
9 |
|
10 |
# Cargar las variables de entorno
|
11 |
load_dotenv()
|
@@ -13,7 +11,7 @@ load_dotenv()
|
|
13 |
# Configurar la API de Google
|
14 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
15 |
|
16 |
-
# Función para generar
|
17 |
@st.cache_resource
|
18 |
def get_model(temperature):
|
19 |
generation_config = {
|
@@ -21,39 +19,39 @@ def get_model(temperature):
|
|
21 |
}
|
22 |
return genai.GenerativeModel('gemini-2.0-flash', generation_config=generation_config)
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
return "Por favor, completa todos los campos requeridos."
|
28 |
|
29 |
model = get_model(temperature)
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
product,
|
34 |
-
selected_formula,
|
35 |
-
selected_angle
|
36 |
)
|
37 |
|
38 |
-
response = model.generate_content([
|
39 |
-
return response.parts[0].text if response and response.parts else "Error
|
40 |
|
41 |
# Configurar la interfaz de usuario con Streamlit
|
42 |
-
st.set_page_config(page_title="
|
43 |
-
|
44 |
-
# Leer el contenido del archivo manual.md
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
# Mostrar el contenido del manual en el sidebar
|
49 |
-
st.sidebar.markdown(manual_content)
|
|
|
|
|
|
|
|
|
50 |
|
51 |
# Ocultar elementos de la interfaz
|
52 |
st.markdown(styles["main_layout"], unsafe_allow_html=True)
|
53 |
|
54 |
# Centrar el título y el subtítulo
|
55 |
-
st.markdown("<h1 style='text-align: center;'>
|
56 |
-
st.markdown("<h4 style='text-align: center;'>
|
57 |
|
58 |
# Añadir CSS personalizado para el botón
|
59 |
st.markdown(styles["button"], unsafe_allow_html=True)
|
@@ -61,62 +59,44 @@ st.markdown(styles["button"], unsafe_allow_html=True)
|
|
61 |
# Crear columnas
|
62 |
col1, col2 = st.columns([1, 2])
|
63 |
|
64 |
-
#
|
65 |
-
# Inside the column section
|
66 |
with col1:
|
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 |
-
product,
|
107 |
-
temperature,
|
108 |
-
selected_formula,
|
109 |
-
selected_angle
|
110 |
-
)
|
111 |
-
if not isinstance(generated_benefits, str):
|
112 |
-
col2.error("Error al generar beneficios")
|
113 |
-
else:
|
114 |
-
col2.markdown(f"""
|
115 |
-
<div style="{styles['results_container']}">
|
116 |
-
<h3>Beneficios Generados:</h3>
|
117 |
-
<p>{generated_benefits}</p>
|
118 |
-
</div>
|
119 |
-
""", unsafe_allow_html=True)
|
120 |
-
|
121 |
-
else:
|
122 |
-
col2.warning("Por favor, completa todos los campos antes de generar beneficios.")
|
|
|
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()
|
|
|
11 |
# Configurar la API de Google
|
12 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
13 |
|
14 |
+
# Función para generar el perfil de cliente ideal
|
15 |
@st.cache_resource
|
16 |
def get_model(temperature):
|
17 |
generation_config = {
|
|
|
19 |
}
|
20 |
return genai.GenerativeModel('gemini-2.0-flash', generation_config=generation_config)
|
21 |
|
22 |
+
def generate_buyer_persona(product, skills, temperature):
|
23 |
+
if not product or not skills:
|
24 |
+
return "Por favor, completa los campos de producto y habilidades."
|
|
|
25 |
|
26 |
model = get_model(temperature)
|
27 |
+
instruction = create_instruction(
|
28 |
+
product_service=product,
|
29 |
+
skills=skills
|
|
|
|
|
|
|
30 |
)
|
31 |
|
32 |
+
response = model.generate_content([instruction], generation_config={"temperature": temperature})
|
33 |
+
return response.parts[0].text if response and response.parts else "Error generando el perfil de cliente ideal."
|
34 |
|
35 |
# Configurar la interfaz de usuario con Streamlit
|
36 |
+
st.set_page_config(page_title="Generador de Cliente Ideal", page_icon="👤", layout="wide")
|
37 |
+
|
38 |
+
# Leer el contenido del archivo manual.md si existe
|
39 |
+
try:
|
40 |
+
with open("manual.md", "r", encoding="utf-8") as file:
|
41 |
+
manual_content = file.read()
|
42 |
+
# Mostrar el contenido del manual en el sidebar
|
43 |
+
st.sidebar.markdown(manual_content)
|
44 |
+
except FileNotFoundError:
|
45 |
+
st.sidebar.warning("Manual not found. Please create a manual.md file.")
|
46 |
+
except Exception as e:
|
47 |
+
st.sidebar.error(f"Error loading manual: {str(e)}")
|
48 |
|
49 |
# Ocultar elementos de la interfaz
|
50 |
st.markdown(styles["main_layout"], unsafe_allow_html=True)
|
51 |
|
52 |
# Centrar el título y el subtítulo
|
53 |
+
st.markdown("<h1 style='text-align: center;'>Generador de Perfil de Cliente Ideal</h1>", unsafe_allow_html=True)
|
54 |
+
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)
|
55 |
|
56 |
# Añadir CSS personalizado para el botón
|
57 |
st.markdown(styles["button"], unsafe_allow_html=True)
|
|
|
59 |
# Crear columnas
|
60 |
col1, col2 = st.columns([1, 2])
|
61 |
|
62 |
+
# Columna de entrada
|
|
|
63 |
with col1:
|
64 |
+
producto = st.text_input("¿Qué producto o servicio ofreces?", placeholder="Ejemplo: Curso de Inglés")
|
65 |
+
habilidades = st.text_input("¿Cuáles son tus habilidades principales?", placeholder="Ejemplo: Enseñanza, comunicación, diseño de contenidos")
|
66 |
+
|
67 |
+
# Nivel de creatividad con slider
|
68 |
+
creatividad = st.slider("Nivel de creatividad", min_value=0.0, max_value=2.0, value=1.0, step=0.1)
|
69 |
+
|
70 |
+
# Botón para generar
|
71 |
+
submit = st.button("GENERAR PERFIL DE CLIENTE IDEAL")
|
72 |
+
|
73 |
+
# Columna de resultados
|
74 |
+
with col2:
|
75 |
+
if submit:
|
76 |
+
if producto and habilidades:
|
77 |
+
with st.spinner('Generando perfil de cliente ideal...'):
|
78 |
+
perfil_cliente = generate_buyer_persona(
|
79 |
+
producto,
|
80 |
+
habilidades,
|
81 |
+
creatividad
|
82 |
+
)
|
83 |
+
|
84 |
+
if not isinstance(perfil_cliente, str):
|
85 |
+
st.error("Error al generar el perfil de cliente ideal")
|
86 |
+
else:
|
87 |
+
st.markdown(f"""
|
88 |
+
<div style="{styles['results_container']}">
|
89 |
+
<h3>Tu Cliente Ideal</h3>
|
90 |
+
{perfil_cliente}
|
91 |
+
</div>
|
92 |
+
""", unsafe_allow_html=True)
|
93 |
+
|
94 |
+
# Opción para descargar
|
95 |
+
st.download_button(
|
96 |
+
label="Descargar Perfil",
|
97 |
+
data=perfil_cliente,
|
98 |
+
file_name="cliente_ideal.md",
|
99 |
+
mime="text/markdown"
|
100 |
+
)
|
101 |
+
else:
|
102 |
+
st.warning("Por favor, completa los campos de producto y habilidades antes de generar el perfil.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|