Josedcape commited on
Commit
cdb9ff5
verified
1 Parent(s): ea00cc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -29
app.py CHANGED
@@ -228,7 +228,7 @@ def main():
228
 
229
  # Barra lateral
230
  st.sidebar.title("Navegaci贸n")
231
- page = st.sidebar.radio("Ir a", ["P谩gina Principal", "Pedidos", "Calcular Pedido","Notificaciones"])
232
 
233
  # Importar y mostrar la p谩gina seleccionada
234
  if page == "P谩gina Principal":
@@ -244,39 +244,38 @@ def main():
244
  import pages.notificaciones as notificaciones
245
  notificaciones.show()
246
 
247
- # --- 脕rea principal de la aplicaci贸n ---
248
- st.header("馃挰 DELICIAS PARA CADA OCASION ")
249
 
250
- # Carga de archivo PDF
251
- archivo_pdf = st.file_uploader("馃搨 Cargar PDF", type='pdf')
252
 
253
- # --- Chatbot ---
254
- if 'mensajes' not in st.session_state:
255
- st.session_state.mensajes = []
256
 
257
- for mensaje in st.session_state.mensajes:
258
- with st.chat_message(mensaje["role"]):
259
- st.markdown(mensaje["content"])
260
 
261
- pregunta_usuario = st.chat_input("Pregunta:")
262
- if pregunta_usuario:
263
- st.session_state.mensajes.append({"role": "user", "content": pregunta_usuario})
264
- with st.chat_message("user"):
265
- st.markdown(pregunta_usuario)
266
 
267
- if archivo_pdf:
268
- texto_pdf = extraer_texto_pdf(archivo_pdf)
269
- texto_preprocesado = preprocesar_texto(texto_pdf)
270
- else:
271
- texto_preprocesado = "" # Sin contexto de PDF si no se carga un archivo
272
-
273
- # A帽adir spinner mientras se espera la respuesta
274
- with st.spinner("Generando respuesta..."):
275
- respuesta = obtener_respuesta(pregunta_usuario, texto_preprocesado, modelo, temperatura)
276
- st.session_state.mensajes.append({"role": "assistant", "content": respuesta})
277
- with st.chat_message("assistant"):
278
- st.markdown(respuesta)
279
-
280
 
281
  if __name__ == "__main__":
282
  main()
 
228
 
229
  # Barra lateral
230
  st.sidebar.title("Navegaci贸n")
231
+ page = st.sidebar.radio("Ir a", ["P谩gina Principal", "Pedidos", "Calcular Pedido", "Notificaciones"])
232
 
233
  # Importar y mostrar la p谩gina seleccionada
234
  if page == "P谩gina Principal":
 
244
  import pages.notificaciones as notificaciones
245
  notificaciones.show()
246
 
247
+ # --- 脕rea principal de la aplicaci贸n ---
248
+ st.header("馃挰 DELICIAS PARA CADA OCASION ")
249
 
250
+ # Carga de archivo PDF
251
+ archivo_pdf = st.file_uploader("馃搨 Cargar PDF", type='pdf')
252
 
253
+ # --- Chatbot ---
254
+ if 'mensajes' not in st.session_state:
255
+ st.session_state.mensajes = []
256
 
257
+ for mensaje in st.session_state.mensajes:
258
+ with st.chat_message(mensaje["role"]):
259
+ st.markdown(mensaje["content"])
260
 
261
+ pregunta_usuario = st.chat_input("Pregunta:")
262
+ if pregunta_usuario:
263
+ st.session_state.mensajes.append({"role": "user", "content": pregunta_usuario})
264
+ with st.chat_message("user"):
265
+ st.markdown(pregunta_usuario)
266
 
267
+ if archivo_pdf:
268
+ texto_pdf = extraer_texto_pdf(archivo_pdf)
269
+ texto_preprocesado = preprocesar_texto(texto_pdf)
270
+ else:
271
+ texto_preprocesado = "" # Sin contexto de PDF si no se carga un archivo
272
+
273
+ # A帽adir spinner mientras se espera la respuesta
274
+ with st.spinner("Generando respuesta..."):
275
+ respuesta = obtener_respuesta(pregunta_usuario, texto_preprocesado, modelo, temperatura)
276
+ st.session_state.mensajes.append({"role": "assistant", "content": respuesta})
277
+ with st.chat_message("assistant"):
278
+ st.markdown(respuesta)
 
279
 
280
  if __name__ == "__main__":
281
  main()