Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,35 +102,47 @@ st.markdown("""
|
|
| 102 |
</style>
|
| 103 |
""", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
-
#
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
with col1:
|
| 109 |
-
#
|
| 110 |
target_audience = st.text_input("¿Quién es tu público objetivo?")
|
| 111 |
product = st.text_input("¿Qué producto tienes en mente?")
|
| 112 |
|
| 113 |
-
#
|
| 114 |
with st.expander("Personaliza tu párrafo de apertura"):
|
| 115 |
text_type = st.selectbox("Tipo de texto", ["Historia", "Carta de venta", "Correo", "Landing page"])
|
| 116 |
-
length = st.slider("Número de palabras", min_value=50, max_value=
|
| 117 |
mood = st.selectbox("Tono de voz", ["Conversacional", "Formal", "Persuasivo"])
|
| 118 |
-
emotionality = st.selectbox("Emocionalidad del texto", ["Triste", "Feliz", "
|
| 119 |
-
|
| 120 |
-
#
|
| 121 |
submit = st.button("Escribir mi Texto")
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
try:
|
| 126 |
-
#
|
| 127 |
generated_text = get_gemini_response(target_audience, product, text_type, length, mood, emotionality)
|
| 128 |
col2.markdown("""
|
| 129 |
<div style="border: 2px solid #FFCC00; padding: 10px; border-radius: 8px; background-color: #f9f9f9;">
|
| 130 |
<h3>Contenido generado:</h3>
|
| 131 |
<p>{}</p>
|
| 132 |
</div>
|
| 133 |
-
""".format(generated_text), unsafe_allow_html=True) #
|
| 134 |
except ValueError as e:
|
| 135 |
col2.error(f"Error: {str(e)}")
|
| 136 |
else:
|
|
|
|
| 102 |
</style>
|
| 103 |
""", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
+
# Initialize a variable for generated text
|
| 106 |
+
generated_text = "Tu párrafo de apertura aparecera aquí."
|
| 107 |
+
|
| 108 |
+
# Create two columns for the layout (40% and 60%)
|
| 109 |
+
col1, col2 = st.columns([2, 3]) # 2 + 3 = 5 parts in total
|
| 110 |
|
| 111 |
with col1:
|
| 112 |
+
# Create input fields
|
| 113 |
target_audience = st.text_input("¿Quién es tu público objetivo?")
|
| 114 |
product = st.text_input("¿Qué producto tienes en mente?")
|
| 115 |
|
| 116 |
+
# Accordion for customizing the opening paragraph
|
| 117 |
with st.expander("Personaliza tu párrafo de apertura"):
|
| 118 |
text_type = st.selectbox("Tipo de texto", ["Historia", "Carta de venta", "Correo", "Landing page"])
|
| 119 |
+
length = st.slider("Número de palabras", min_value=50, max_value=200, value=100)
|
| 120 |
mood = st.selectbox("Tono de voz", ["Conversacional", "Formal", "Persuasivo"])
|
| 121 |
+
emotionality = st.selectbox("Emocionalidad del texto", ["Triste", "Feliz", "Horror", "Comedia", "Romántico", "Sorpresa", "Desesperación", "Esperanza", "Ira", "Confianza"])
|
| 122 |
+
|
| 123 |
+
# Submit button
|
| 124 |
submit = st.button("Escribir mi Texto")
|
| 125 |
|
| 126 |
+
# Display the result area with a border
|
| 127 |
+
col2.markdown("""
|
| 128 |
+
<div style="border: 2px solid #FFCC00; padding: 10px; border-radius: 8px; background-color: #f9f9f9;">
|
| 129 |
+
<h3>Contenido generado:</h3>
|
| 130 |
+
<p>{}</p>
|
| 131 |
+
</div>
|
| 132 |
+
""".format(generated_text), unsafe_allow_html=True)
|
| 133 |
+
|
| 134 |
+
# Button to generate text (outside the accordion)
|
| 135 |
+
if submit:
|
| 136 |
+
if target_audience and product: # Check if target audience and product are provided
|
| 137 |
try:
|
| 138 |
+
# Get the response from the model
|
| 139 |
generated_text = get_gemini_response(target_audience, product, text_type, length, mood, emotionality)
|
| 140 |
col2.markdown("""
|
| 141 |
<div style="border: 2px solid #FFCC00; padding: 10px; border-radius: 8px; background-color: #f9f9f9;">
|
| 142 |
<h3>Contenido generado:</h3>
|
| 143 |
<p>{}</p>
|
| 144 |
</div>
|
| 145 |
+
""".format(generated_text), unsafe_allow_html=True) # Update with generated text
|
| 146 |
except ValueError as e:
|
| 147 |
col2.error(f"Error: {str(e)}")
|
| 148 |
else:
|