Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,36 +200,33 @@ def enviar_imagen():
|
|
| 200 |
# Secci贸n para enviar im谩genes
|
| 201 |
enviar_imagen()
|
| 202 |
|
| 203 |
-
pregunta_usuario = st.text_input("Escribe tu pregunta sobre la Biblia:")
|
|
|
|
|
|
|
| 204 |
if st.button("Enviar"):
|
| 205 |
-
if pregunta_usuario:
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
with st.spinner("Generando respuesta..."):
|
| 211 |
with st.empty():
|
| 212 |
spinner = st.markdown('<div class="spinner"></div>', unsafe_allow_html=True)
|
| 213 |
time.sleep(1) # Simulaci贸n del tiempo de procesamiento
|
| 214 |
spinner.empty()
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
st.
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
# Convertir texto a voz
|
| 223 |
-
audio_base64 = text_to_speech_base64(respuesta)
|
| 224 |
-
audio_html = f"""
|
| 225 |
-
<audio autoplay>
|
| 226 |
-
<source src="data:audio/mp3;base64,{audio_base64}" type="audio/mp3">
|
| 227 |
-
</audio>
|
| 228 |
-
"""
|
| 229 |
-
st.markdown(audio_html, unsafe_allow_html=True)
|
| 230 |
-
else:
|
| 231 |
-
st.warning("Por favor, ingresa una pregunta antes de enviar.")
|
| 232 |
-
|
| 233 |
-
# Gesti贸n de pedidos
|
| 234 |
-
st.subheader("馃搵 Gesti贸n de Pedidos")
|
| 235 |
-
menu_csv_path = "menu.csv" # Ruta al archivo
|
|
|
|
| 200 |
# Secci贸n para enviar im谩genes
|
| 201 |
enviar_imagen()
|
| 202 |
|
| 203 |
+
pregunta_usuario = st.text_input("Escribe tu pregunta sobre la Biblia:", key="pregunta_input")
|
| 204 |
+
imagen_usuario = st.file_uploader("Sube una imagen (opcional):", type=["png", "jpg", "jpeg"])
|
| 205 |
+
|
| 206 |
if st.button("Enviar"):
|
| 207 |
+
if pregunta_usuario or imagen_usuario:
|
| 208 |
+
if pregunta_usuario:
|
| 209 |
+
st.session_state.mensajes.append({"role": "user", "content": pregunta_usuario, "timestamp": time.time()})
|
| 210 |
+
with st.chat_message("user"):
|
| 211 |
+
st.markdown(pregunta_usuario)
|
| 212 |
+
|
| 213 |
+
if imagen_usuario:
|
| 214 |
+
imagen_bytes = imagen_usuario.getvalue()
|
| 215 |
+
st.session_state.mensajes.append({"role": "user", "content": imagen_bytes, "timestamp": time.time()})
|
| 216 |
+
with st.chat_message("user"):
|
| 217 |
+
st.image(imagen_bytes)
|
| 218 |
+
|
| 219 |
+
st.session_state.pregunta_input = "" # Borrar el campo de texto despu茅s de enviar la pregunta
|
| 220 |
|
| 221 |
with st.spinner("Generando respuesta..."):
|
| 222 |
with st.empty():
|
| 223 |
spinner = st.markdown('<div class="spinner"></div>', unsafe_allow_html=True)
|
| 224 |
time.sleep(1) # Simulaci贸n del tiempo de procesamiento
|
| 225 |
spinner.empty()
|
| 226 |
+
|
| 227 |
+
if pregunta_usuario:
|
| 228 |
+
respuesta = obtener_respuesta(pregunta_usuario)
|
| 229 |
+
st.session_state.mensajes.append({"role": "assistant", "content": respuesta, "timestamp": time.time()})
|
| 230 |
+
with st.chat_message("assistant"):
|
| 231 |
+
st.markdown(respuesta)
|
| 232 |
+
st.video("https://cdn.pika.art/v1/0fe46d03-efd2-49d8-86a2-923076
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|