Josedcape commited on
Commit
dbc7673
·
verified ·
1 Parent(s): f588a2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +125 -127
app.py CHANGED
@@ -300,7 +300,7 @@ def buscar_datos_guardados():
300
 
301
  # Link to download the file
302
  try:
303
- with open(os.path.join(carpeta, archivo_seleccionado), 'rb') as file):
304
  st.download_button(
305
  label="📥 Descargar Archivo TXT",
306
  data=file,
@@ -457,6 +457,129 @@ def mostrar_recomendaciones():
457
  st.title("⭐ Recomendaciones")
458
  st.write("Aquí puedes encontrar recomendaciones y consejos útiles.")
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  def mostrar_galatea_asistente():
461
  st.markdown(
462
  """
@@ -529,15 +652,10 @@ def manejar_pregunta_usuario(pregunta_usuario, archivo_pdf=None):
529
  with st.chat_message("user"):
530
  st.markdown(pregunta_usuario)
531
 
532
- texto_preprocesado = ""
533
-
534
  if archivo_pdf:
535
  texto_pdf = extraer_texto_pdf(archivo_pdf)
536
  texto_preprocesado = preprocesar_texto(texto_pdf)
537
- else:
538
- with open(os.path.join("assets", "instrucciones.pdf"), "rb") as file:
539
- texto_pdf = extraer_texto_pdf(file)
540
- texto_preprocesado = preprocesar_texto(texto_pdf)
541
 
542
  # Obtener respuesta del modelo usando Assistant ID si está presente
543
  assistant_id = st.session_state.get('assistant_id', '')
@@ -662,125 +780,5 @@ def capturar_voz():
662
  unsafe_allow_html=True
663
  )
664
 
665
- def main():
666
- st.set_page_config(page_title="Galatea OMARDENT", layout="wide")
667
-
668
- # Inicializar el estado de la sesión
669
- if 'modelo' not in st.session_state:
670
- st.session_state['modelo'] = "gpt-3.5-turbo"
671
- if 'temperatura' not in st.session_state:
672
- st.session_state['temperatura'] = 0.5
673
- if 'mensajes_chat' not in st.session_state:
674
- st.session_state['mensajes_chat'] = []
675
- if 'transcripcion_voz' not in st.session_state:
676
- st.session_state['transcripcion_voz'] = ""
677
- if 'imagen_asistente' not in st.session_state:
678
- st.session_state['imagen_asistente'] = None
679
- if 'video_estado' not in st.session_state:
680
- st.session_state['video_estado'] = 'paused'
681
- if 'assistant_id' not in st.session_state:
682
- st.session_state['assistant_id'] = 'asst_4ZYvBvf4IUVQPjnugSZGLdV2'
683
- if 'presupuesto_texto' not in st.session_state:
684
- st.session_state['presupuesto_texto'] = ''
685
- if 'mostrar_chat' not in st.session_state:
686
- st.session_state['mostrar_chat'] = False
687
-
688
- # Barra lateral
689
- ruta_logo = os.path.join("assets", "Logo Omardent.png")
690
- if os.path.exists(ruta_logo):
691
- st.sidebar.image(ruta_logo, use_column_width=True)
692
- else:
693
- st.sidebar.warning(f"Error: No se pudo encontrar la imagen en la ruta: {ruta_logo}")
694
-
695
- st.sidebar.title("🤖 Galatea OMARDENT")
696
- st.sidebar.markdown("---")
697
- st.sidebar.subheader("🧠 Configuración del Modelo")
698
- st.session_state['modelo'] = st.sidebar.selectbox(
699
- "Selecciona el modelo:",
700
- ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k", "gpt-4o"],
701
- index=0,
702
- key='modelo_selectbox', # Clave única
703
- help="Elige el modelo de lenguaje de OpenAI que prefieras."
704
- )
705
- st.sidebar.markdown("---")
706
- st.session_state['temperatura'] = st.sidebar.slider(
707
- "🌡️ Temperatura",
708
- min_value=0.0, max_value=1.0,
709
- value=st.session_state['temperatura'],
710
- step=0.1,
711
- key='temperatura_slider' # Clave única
712
- )
713
- assistant_id = st.sidebar.text_input("Assistant ID", key="assistant_id", help="Introduce el Assistant ID del playground de OpenAI")
714
-
715
- st.sidebar.markdown("---")
716
- st.sidebar.subheader("🌟 Navegación")
717
- lateral_page = st.sidebar.radio("Ir a", ["Página Principal", "Gestión de Trabajos", "Gestión de Insumos", "Registro de Radiografías", "Buscar Datos", "Notificaciones", "Recomendaciones", "Asistente de Presupuestos", "Comunicación", "Asistente de Agendamiento"])
718
-
719
- top_page = st.selectbox("Navegación Superior", ["Página Principal", "Galatea-Asistente"])
720
-
721
- if top_page == "Galatea-Asistente":
722
- mostrar_galatea_asistente()
723
- else:
724
- if lateral_page == "Página Principal":
725
- mostrar_pagina_principal()
726
- elif lateral_page == "Gestión de Trabajos":
727
- flujo_laboratorio()
728
- elif lateral_page == "Gestión de Insumos":
729
- flujo_insumos()
730
- elif lateral_page == "Registro de Radiografías":
731
- flujo_radiografias()
732
- elif lateral_page == "Buscar Datos":
733
- buscar_datos_guardados()
734
- elif lateral_page == "Notificaciones":
735
- generar_notificaciones_pendientes()
736
- elif lateral_page == "Recomendaciones":
737
- mostrar_recomendaciones()
738
- elif lateral_page == "Asistente de Presupuestos":
739
- flujo_presupuestos()
740
- elif lateral_page == "Comunicación":
741
- st.write("Página de Comunicación") # Implementar según sea necesario
742
- elif lateral_page == "Asistente de Agendamiento":
743
- st.write("Página de Agendamiento") # Implementar según sea necesario
744
-
745
- def mostrar_pagina_principal():
746
- st.title("VIRTUAL OMARDENT AI-BOTIDINAMIX")
747
- st.markdown(
748
- f"""
749
- <style>
750
- #video-container {{
751
- position: relative;
752
- width: 100%;
753
- padding-bottom: 56.25%;
754
- background-color: lightblue;
755
- overflow: hidden;
756
- }}
757
- #background-video {{
758
- position: absolute;
759
- top: 0;
760
- left: 0;
761
- width: 100%;
762
- height: 100%;
763
- }}
764
- </style>
765
- <div id="video-container">
766
- <video id="background-video" autoplay loop muted playsinline>
767
- <source src="https://cdn.leonardo.ai/users/645c3d5c-ca1b-4ce8-aefa-a091494e0d09/generations/0c4f0fe7-5937-4644-b984-bdbd95018990/0c4f0fe7-5937-4644-b984-bdbd95018990.mp4" type="video/mp4">
768
- </video>
769
- </div>
770
- """,
771
- unsafe_allow_html=True
772
- )
773
-
774
- archivo_pdf = st.file_uploader("📂 Cargar PDF", type='pdf', key='chat_pdf')
775
-
776
- col1, col2 = st.columns([3, 1])
777
- with col1:
778
- pregunta_usuario = st.text_input("Pregunta:", key='unique_chat_input_key', value=st.session_state['transcripcion_voz'])
779
- with col2:
780
- capturar_voz()
781
-
782
- if pregunta_usuario:
783
- manejar_pregunta_usuario(pregunta_usuario, archivo_pdf)
784
-
785
  if __name__ == "__main__":
786
  main()
 
300
 
301
  # Link to download the file
302
  try:
303
+ with open(os.path.join(carpeta, archivo_seleccionado), 'rb') as file:
304
  st.download_button(
305
  label="📥 Descargar Archivo TXT",
306
  data=file,
 
457
  st.title("⭐ Recomendaciones")
458
  st.write("Aquí puedes encontrar recomendaciones y consejos útiles.")
459
 
460
+ def main():
461
+ st.set_page_config(page_title="Galatea OMARDENT", layout="wide")
462
+
463
+ # Inicializar el estado de la sesión
464
+ if 'modelo' not in st.session_state:
465
+ st.session_state['modelo'] = "gpt-3.5-turbo"
466
+ if 'temperatura' not in st.session_state:
467
+ st.session_state['temperatura'] = 0.5
468
+ if 'mensajes_chat' not in st.session_state:
469
+ st.session_state['mensajes_chat'] = []
470
+ if 'transcripcion_voz' not in st.session_state:
471
+ st.session_state['transcripcion_voz'] = ""
472
+ if 'imagen_asistente' not in st.session_state:
473
+ st.session_state['imagen_asistente'] = None
474
+ if 'video_estado' not in st.session_state:
475
+ st.session_state['video_estado'] = 'paused'
476
+ if 'assistant_id' not in st.session_state:
477
+ st.session_state['assistant_id'] = 'asst_4ZYvBvf4IUVQPjnugSZGLdV2'
478
+ if 'presupuesto_texto' not in st.session_state:
479
+ st.session_state['presupuesto_texto'] = ''
480
+ if 'mostrar_chat' not in st.session_state:
481
+ st.session_state['mostrar_chat'] = False
482
+ if 'texto_pdf' not in st.session_state:
483
+ with open("assets/instrucciones.pdf", "rb") as file:
484
+ st.session_state['texto_pdf'] = extraer_texto_pdf(file)
485
+
486
+ # Barra lateral
487
+ ruta_logo = os.path.join("assets", "Logo Omardent.png")
488
+ if os.path.exists(ruta_logo):
489
+ st.sidebar.image(ruta_logo, use_column_width=True)
490
+ else:
491
+ st.sidebar.warning(f"Error: No se pudo encontrar la imagen en la ruta: {ruta_logo}")
492
+
493
+ st.sidebar.title("🤖 Galatea OMARDENT")
494
+ st.sidebar.markdown("---")
495
+ st.sidebar.subheader("🧠 Configuración del Modelo")
496
+ st.session_state['modelo'] = st.sidebar.selectbox(
497
+ "Selecciona el modelo:",
498
+ ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k", "gpt-4o"],
499
+ index=0,
500
+ key='modelo_selectbox', # Clave única
501
+ help="Elige el modelo de lenguaje de OpenAI que prefieras."
502
+ )
503
+ st.sidebar.markdown("---")
504
+ st.session_state['temperatura'] = st.sidebar.slider(
505
+ "🌡️ Temperatura",
506
+ min_value=0.0, max_value=1.0,
507
+ value=st.session_state['temperatura'],
508
+ step=0.1,
509
+ key='temperatura_slider' # Clave única
510
+ )
511
+ assistant_id = st.sidebar.text_input("Assistant ID", key="assistant_id", help="Introduce el Assistant ID del playground de OpenAI")
512
+
513
+ st.sidebar.markdown("---")
514
+ st.sidebar.subheader("🌟 Navegación")
515
+ lateral_page = st.sidebar.radio("Ir a", ["Página Principal", "Gestión de Trabajos", "Gestión de Insumos", "Registro de Radiografías", "Buscar Datos", "Notificaciones", "Recomendaciones", "Asistente de Presupuestos", "Comunicación", "Asistente de Agendamiento"])
516
+
517
+ top_page = st.selectbox("Navegación Superior", ["Página Principal", "Galatea-Asistente"])
518
+
519
+ if top_page == "Galatea-Asistente":
520
+ mostrar_galatea_asistente()
521
+ else:
522
+ if lateral_page == "Página Principal":
523
+ mostrar_pagina_principal()
524
+ elif lateral_page == "Gestión de Trabajos":
525
+ flujo_laboratorio()
526
+ elif lateral_page == "Gestión de Insumos":
527
+ flujo_insumos()
528
+ elif lateral_page == "Registro de Radiografías":
529
+ flujo_radiografias()
530
+ elif lateral_page == "Buscar Datos":
531
+ buscar_datos_guardados()
532
+ elif lateral_page == "Notificaciones":
533
+ generar_notificaciones_pendientes()
534
+ elif lateral_page == "Recomendaciones":
535
+ mostrar_recomendaciones()
536
+ elif lateral_page == "Asistente de Presupuestos":
537
+ flujo_presupuestos()
538
+ elif lateral_page == "Comunicación":
539
+ st.write("Página de Comunicación") # Implementar según sea necesario
540
+ elif lateral_page == "Asistente de Agendamiento":
541
+ st.write("Página de Agendamiento") # Implementar según sea necesario
542
+
543
+ def mostrar_pagina_principal():
544
+ st.title("VIRTUAL OMARDENT AI-BOTIDINAMIX")
545
+ st.markdown(
546
+ f"""
547
+ <style>
548
+ #video-container {{
549
+ position: relative;
550
+ width: 100%;
551
+ padding-bottom: 56.25%;
552
+ background-color: lightblue;
553
+ overflow: hidden;
554
+ }}
555
+ #background-video {{
556
+ position: absolute;
557
+ top: 0;
558
+ left: 0;
559
+ width: 100%;
560
+ height: 100%;
561
+ }}
562
+ </style>
563
+ <div id="video-container">
564
+ <video id="background-video" autoplay loop muted playsinline>
565
+ <source src="https://cdn.leonardo.ai/users/645c3d5c-ca1b-4ce8-aefa-a091494e0d09/generations/0c4f0fe7-5937-4644-b984-bdbd95018990/0c4f0fe7-5937-4644-b984-bdbd95018990.mp4" type="video/mp4">
566
+ </video>
567
+ </div>
568
+ """,
569
+ unsafe_allow_html=True
570
+ )
571
+
572
+ archivo_pdf = st.file_uploader("📂 Cargar PDF", type='pdf', key='chat_pdf')
573
+
574
+ col1, col2 = st.columns([3, 1])
575
+ with col1:
576
+ pregunta_usuario = st.text_input("Pregunta:", key='unique_chat_input_key', value=st.session_state['transcripcion_voz'])
577
+ with col2:
578
+ capturar_voz()
579
+
580
+ if pregunta_usuario:
581
+ manejar_pregunta_usuario(pregunta_usuario, archivo_pdf)
582
+
583
  def mostrar_galatea_asistente():
584
  st.markdown(
585
  """
 
652
  with st.chat_message("user"):
653
  st.markdown(pregunta_usuario)
654
 
655
+ texto_preprocesado = st.session_state.get('texto_pdf', "")
 
656
  if archivo_pdf:
657
  texto_pdf = extraer_texto_pdf(archivo_pdf)
658
  texto_preprocesado = preprocesar_texto(texto_pdf)
 
 
 
 
659
 
660
  # Obtener respuesta del modelo usando Assistant ID si está presente
661
  assistant_id = st.session_state.get('assistant_id', '')
 
780
  unsafe_allow_html=True
781
  )
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  if __name__ == "__main__":
784
  main()