Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import time
|
|
| 7 |
import base64
|
| 8 |
import tempfile
|
| 9 |
from google.cloud import texttospeech
|
|
|
|
| 10 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode, AudioProcessorBase
|
| 11 |
|
| 12 |
# Configuración de la clave API
|
|
@@ -173,62 +174,54 @@ st.markdown(
|
|
| 173 |
)
|
| 174 |
|
| 175 |
# Encabezado
|
| 176 |
-
st.image("
|
| 177 |
st.title("📖 LOS CÓDIGOS DE DIOS - BOTIDINAMIX AI")
|
| 178 |
st.markdown("Bienvenido al Asistente Teológico, donde puedes preguntar sobre interpretaciones y reflexiones bíblicas.")
|
| 179 |
|
| 180 |
-
#
|
| 181 |
-
st.
|
| 182 |
-
|
| 183 |
-
st.session_state.mensajes = []
|
| 184 |
-
|
| 185 |
-
for mensaje in st.session_state.mensajes:
|
| 186 |
-
with st.chat_message(mensaje["role"]):
|
| 187 |
-
if isinstance(mensaje["content"], str):
|
| 188 |
-
st.markdown(mensaje["content"])
|
| 189 |
-
elif isinstance(mensaje["content"], bytes):
|
| 190 |
-
st.image(mensaje["content"])
|
| 191 |
-
|
| 192 |
-
# Función para manejar el envío de imágenes
|
| 193 |
-
def enviar_imagen():
|
| 194 |
-
imagen = st.file_uploader("Sube una imagen", type=["png", "jpg", "jpeg"])
|
| 195 |
-
if imagen is not None:
|
| 196 |
-
st.session_state.mensajes.append({"role": "user", "content": imagen.getvalue(), "timestamp": time.time()})
|
| 197 |
-
with st.chat_message("user"):
|
| 198 |
-
st.image(imagen)
|
| 199 |
-
|
| 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 |
-
|
| 229 |
-
st.
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import base64
|
| 8 |
import tempfile
|
| 9 |
from google.cloud import texttospeech
|
| 10 |
+
from google.cloud import speech
|
| 11 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode, AudioProcessorBase
|
| 12 |
|
| 13 |
# Configuración de la clave API
|
|
|
|
| 174 |
)
|
| 175 |
|
| 176 |
# Encabezado
|
| 177 |
+
st.image("biblia.jpg")
|
| 178 |
st.title("📖 LOS CÓDIGOS DE DIOS - BOTIDINAMIX AI")
|
| 179 |
st.markdown("Bienvenido al Asistente Teológico, donde puedes preguntar sobre interpretaciones y reflexiones bíblicas.")
|
| 180 |
|
| 181 |
+
# Barra lateral para la navegación
|
| 182 |
+
st.sidebar.title("Navegación")
|
| 183 |
+
page = st.sidebar.selectbox("Selecciona una página", ["Chat Asistente", "Gestión de Pedidos", "Generador de Frases Bíblicas"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
if page == "Chat Asistente":
|
| 186 |
+
# Chat con el asistente
|
| 187 |
+
st.subheader("🗣️ Chat con el Asistente")
|
| 188 |
+
if 'mensajes' not in st.session_state:
|
| 189 |
+
st.session_state.mensajes = []
|
| 190 |
+
|
| 191 |
+
for mensaje in st.session_state.mensajes:
|
| 192 |
+
with st.chat_message(mensaje["role"]):
|
| 193 |
+
if isinstance(mensaje["content"], str):
|
| 194 |
+
st.markdown(mensaje["content"])
|
| 195 |
+
elif isinstance(mensaje["content"], bytes):
|
| 196 |
+
st.image(mensaje["content"])
|
| 197 |
+
|
| 198 |
+
pregunta_usuario = st.text_input("Escribe tu pregunta sobre la Biblia:", key="pregunta_input")
|
| 199 |
+
imagen_usuario = st.file_uploader("Sube una imagen (opcional):", type=["png", "jpg", "jpeg"])
|
| 200 |
+
|
| 201 |
+
if st.button("Enviar"):
|
| 202 |
+
if pregunta_usuario or imagen_usuario:
|
| 203 |
if pregunta_usuario:
|
| 204 |
+
st.session_state.mensajes.append({"role": "user", "content": pregunta_usuario, "timestamp": time.time()})
|
| 205 |
+
with st.chat_message("user"):
|
| 206 |
+
st.markdown(pregunta_usuario)
|
| 207 |
+
|
| 208 |
+
if imagen_usuario:
|
| 209 |
+
imagen_bytes = imagen_usuario.getvalue()
|
| 210 |
+
st.session_state.mensajes.append({"role": "user", "content": imagen_bytes, "timestamp": time.time()})
|
| 211 |
+
with st.chat_message("user"):
|
| 212 |
+
st.image(imagen_bytes)
|
| 213 |
+
|
| 214 |
+
st.session_state.pregunta_input = "" # Borrar el campo de texto después de enviar la pregunta
|
| 215 |
+
|
| 216 |
+
with st.spinner("Generando respuesta..."):
|
| 217 |
+
with st.empty():
|
| 218 |
+
spinner = st.markdown('<div class="spinner"></div>', unsafe_allow_html=True)
|
| 219 |
+
time.sleep(1) # Simulación del tiempo de procesamiento
|
| 220 |
+
spinner.empty()
|
| 221 |
+
|
| 222 |
+
if pregunta_usuario:
|
| 223 |
+
respuesta = obtener_respuesta(pregunta_usuario)
|
| 224 |
+
st.session_state.mensajes.append({"role": "assistant", "content": respuesta, "timestamp": time.time()})
|
| 225 |
+
with st.chat_message("assistant"):
|
| 226 |
+
st.markdown(respuesta)
|
| 227 |
+
st.video("https://cdn.pika.art/v1/0fe46d03-efd2-49d8-86a2-9230769af8
|