Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,22 +41,22 @@ col1, col2 = st.columns([4, 6])
|
|
41 |
|
42 |
# Main input section in left column
|
43 |
with col1:
|
44 |
-
skills = st.text_area('💪
|
45 |
-
help='
|
46 |
-
product_service = st.text_area('🎯
|
47 |
-
help='Describe
|
48 |
|
49 |
# Accordion for additional settings
|
50 |
-
with st.expander('⚙️
|
51 |
-
target_audience = st.text_area('👥
|
52 |
-
help='Describe
|
53 |
-
temperature = st.slider('🌡️
|
54 |
-
help='
|
55 |
|
56 |
# Generate button with callback
|
57 |
def generate_offer():
|
58 |
if not skills or not product_service:
|
59 |
-
st.error('
|
60 |
else:
|
61 |
# Set submitted flag to True
|
62 |
st.session_state.submitted = True
|
@@ -66,13 +66,13 @@ with col1:
|
|
66 |
st.session_state.target_audience = target_audience
|
67 |
st.session_state.temperature = temperature
|
68 |
|
69 |
-
st.button('
|
70 |
|
71 |
# Results column
|
72 |
with col2:
|
73 |
# Check if form has been submitted
|
74 |
if st.session_state.submitted:
|
75 |
-
with st.spinner('
|
76 |
prompt = f"""Based on the following information, create a compelling offer:
|
77 |
Skills: {st.session_state.skills}
|
78 |
Product/Service: {st.session_state.product_service}
|
@@ -88,13 +88,22 @@ with col2:
|
|
88 |
# Pass the generation config to generate_content
|
89 |
response = model.generate_content(prompt, generation_config=generation_config)
|
90 |
st.session_state.offer_result = response.text
|
91 |
-
st.success('✨ Your offer is ready!')
|
92 |
|
93 |
-
# Display result
|
94 |
-
st.markdown('### 📝
|
95 |
st.markdown(st.session_state.offer_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
except Exception as e:
|
97 |
-
st.error(f'
|
98 |
st.session_state.submitted = False
|
99 |
|
100 |
# Footer
|
|
|
41 |
|
42 |
# Main input section in left column
|
43 |
with col1:
|
44 |
+
skills = st.text_area('💪 Tus Habilidades', height=70,
|
45 |
+
help='Lista tus habilidades y experiencia clave')
|
46 |
+
product_service = st.text_area('🎯 Producto/Servicio', height=70,
|
47 |
+
help='Describe tu producto o servicio')
|
48 |
|
49 |
# Accordion for additional settings
|
50 |
+
with st.expander('⚙️ Configuración Avanzada'):
|
51 |
+
target_audience = st.text_area('👥 Público Objetivo', height=70,
|
52 |
+
help='Describe tu cliente o público ideal')
|
53 |
+
temperature = st.slider('🌡️ Nivel de Creatividad', min_value=0.0, max_value=2.0, value=0.7,
|
54 |
+
help='Valores más altos hacen que el resultado sea más creativo pero menos enfocado')
|
55 |
|
56 |
# Generate button with callback
|
57 |
def generate_offer():
|
58 |
if not skills or not product_service:
|
59 |
+
st.error('Por favor completa los campos de Habilidades y Producto/Servicio')
|
60 |
else:
|
61 |
# Set submitted flag to True
|
62 |
st.session_state.submitted = True
|
|
|
66 |
st.session_state.target_audience = target_audience
|
67 |
st.session_state.temperature = temperature
|
68 |
|
69 |
+
st.button('Generar Oferta 🎉', on_click=generate_offer)
|
70 |
|
71 |
# Results column
|
72 |
with col2:
|
73 |
# Check if form has been submitted
|
74 |
if st.session_state.submitted:
|
75 |
+
with st.spinner('Creando tu oferta perfecta...'):
|
76 |
prompt = f"""Based on the following information, create a compelling offer:
|
77 |
Skills: {st.session_state.skills}
|
78 |
Product/Service: {st.session_state.product_service}
|
|
|
88 |
# Pass the generation config to generate_content
|
89 |
response = model.generate_content(prompt, generation_config=generation_config)
|
90 |
st.session_state.offer_result = response.text
|
|
|
91 |
|
92 |
+
# Display result (removed the "Your offer is ready!" message)
|
93 |
+
st.markdown('### 📝 Oferta Generada')
|
94 |
st.markdown(st.session_state.offer_result)
|
95 |
+
|
96 |
+
# Add download button below the result with 80% width
|
97 |
+
col_download, col_empty = st.columns([8, 2])
|
98 |
+
with col_download:
|
99 |
+
st.download_button(
|
100 |
+
label="Descargar Oferta",
|
101 |
+
data=st.session_state.offer_result,
|
102 |
+
file_name="oferta_generada.txt",
|
103 |
+
mime="text/plain"
|
104 |
+
)
|
105 |
except Exception as e:
|
106 |
+
st.error(f'Ocurrió un error: {str(e)}')
|
107 |
st.session_state.submitted = False
|
108 |
|
109 |
# Footer
|