Spaces:
Sleeping
Sleeping
File size: 1,706 Bytes
88bf058 785d551 88bf058 69b5d49 88bf058 69b5d49 88bf058 69b5d49 88bf058 46c159e 232908b 46c159e 88bf058 46c159e 88bf058 4c09913 88bf058 46c159e 88bf058 46c159e 88bf058 46c159e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import gradio as gr
from utils_gdmk import (
inicializar_grafo, cargar_normativas, cargar_estudiantes, mostrar_detalles,
visualizar_grafo, agregar_aporte
)
# Initialize graph before launching UI
inicializar_grafo()
normativas = cargar_normativas()
estudiantes = cargar_estudiantes()
coleccion = "normativa_peruana_gestion_riesgos"
coleccion = "propuestas_gestion_incertidumbre"
norm_options = [norm['nombre'] for norm in normativas[coleccion]
student_names = estudiantes["estudiantes"]
# Gradio Interface
iface = gr.Blocks()
with iface:
gr.Markdown("# Foro Dinámico con Visualización de Red")
with gr.Row():
gr.Markdown('## Selección del Documento')
normativa_dropdown = gr.Dropdown(choices=norm_options, label="Documentos a Explorar")
normativa_html = gr.HTML()
# 📌 Update HTML when a norm is selected
normativa_dropdown.change(fn=mostrar_detalles, inputs=normativa_dropdown, outputs=normativa_html)
# 📌 Graph Display
with gr.Row():
gr.Markdown("## Red de Aportes:")
graph_output = gr.Image(visualizar_grafo(), label="Red de Aportes")
# 📌 Input Fields
with gr.Row():
nombre = gr.Dropdown(choices=student_names, label="Nombre del Estudiante")
enfoque = gr.Radio(["Determinista", "Sistémico", "Evolutivo", "Cognitivo"], label="Enfoque")
with gr.Row():
texto = gr.Textbox(label="Tu aporte")
# 📌 Submit Button (Now Uses `normativa_dropdown` Directly)
submit_button = gr.Button("Agregar Aporte")
submit_button.click(
fn=agregar_aporte,
inputs=[nombre, enfoque, normativa_dropdown, texto],
outputs=graph_output
)
iface.launch(share=True) |