Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from utils import (
|
| 3 |
+
inicializar_grafo, cargar_normativas, cargar_estudiantes, mostrar_detalles,
|
| 4 |
+
visualizar_grafo, agregar_aporte
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
# Initialize graph before launching UI
|
| 8 |
+
inicializar_grafo()
|
| 9 |
+
normativas = cargar_normativas()
|
| 10 |
+
estudiantes = cargar_estudiantes()
|
| 11 |
+
|
| 12 |
+
norm_options = [norm['nombre'] for norm in normativas["normativa_peruana_gestion_riesgos"]]
|
| 13 |
+
student_names = estudiantes["estudiantes"]
|
| 14 |
+
|
| 15 |
+
# Gradio Interface
|
| 16 |
+
iface = gr.Blocks()
|
| 17 |
+
|
| 18 |
+
with iface:
|
| 19 |
+
gr.Markdown("# Foro Din谩mico con Visualizaci贸n de Red")
|
| 20 |
+
|
| 21 |
+
with gr.Row():
|
| 22 |
+
gr.Markdown('## Selecci贸n de Norma')
|
| 23 |
+
|
| 24 |
+
normativa_dropdown = gr.Dropdown(choices=norm_options, label="Normativas")
|
| 25 |
+
normativa_html = gr.HTML()
|
| 26 |
+
norma_field = gr.Textbox(label="Norma", interactive=False)
|
| 27 |
+
|
| 28 |
+
normativa_dropdown.change(fn=mostrar_detalles, inputs=normativa_dropdown, outputs=[normativa_html, norma_field])
|
| 29 |
+
|
| 30 |
+
with gr.Row():
|
| 31 |
+
gr.Markdown("## Red de Aportes:")
|
| 32 |
+
graph_output = gr.Image(visualizar_grafo(), label="Red de Aportes")
|
| 33 |
+
|
| 34 |
+
with gr.Row():
|
| 35 |
+
nombre = gr.Dropdown(choices=student_names, label="Nombre del Estudiante")
|
| 36 |
+
enfoque = gr.Radio(["Determinista", "Sist茅mico"], label="Enfoque")
|
| 37 |
+
|
| 38 |
+
with gr.Row():
|
| 39 |
+
texto = gr.Textbox(label="Tu aporte")
|
| 40 |
+
|
| 41 |
+
submit_button = gr.Button("Agregar Aporte")
|
| 42 |
+
submit_button.click(fn=agregar_aporte, inputs=[nombre, enfoque, norma_field, texto], outputs=graph_output)
|
| 43 |
+
|
| 44 |
+
iface.launch(share=True)
|