Spaces:
Sleeping
Sleeping
| 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() | |
| norm_options = [norm['nombre'] for norm in normativas["normativa_peruana_gestion_riesgos"]] | |
| 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 de Norma') | |
| normativa_dropdown = gr.Dropdown(choices=norm_options, label="Normativas") | |
| normativa_html = gr.HTML() | |
| norma_field = gr.Textbox(label="Norma", interactive=False) | |
| normativa_dropdown.change(fn=mostrar_detalles, inputs=normativa_dropdown, outputs=[normativa_html, norma_field]) | |
| with gr.Row(): | |
| gr.Markdown("## Red de Aportes:") | |
| graph_output = gr.Image(visualizar_grafo(), label="Red de Aportes") | |
| with gr.Row(): | |
| nombre = gr.Dropdown(choices=student_names, label="Nombre del Estudiante") | |
| enfoque = gr.Radio(["Determinista", "Sist茅mico"], label="Enfoque") | |
| with gr.Row(): | |
| texto = gr.Textbox(label="Tu aporte") | |
| submit_button = gr.Button("Agregar Aporte") | |
| submit_button.click(fn=agregar_aporte, inputs=[nombre, enfoque, norma_field, texto], outputs=graph_output) | |
| iface.launch(share=True) | |