jcmachicao's picture
Update app.py
e8186f6 verified
import gradio as gr
import networkx as nx
from utils_gdmk import (
inicializar_grafo, cargar_vocabulario, cargar_nombres, visualizar_grafo,
agregar_aporte, reload_data
)
G = nx.DiGraph()
inicializar_grafo() # Llamar antes de mostrar el grafo
students = cargar_nombres("nombres_postdoc.txt")
VOCABULARY = cargar_vocabulario("vocabulario_postdoc.txt")
def iniciar_interfaz():
iface = gr.Blocks()
with iface:
with gr.Row():
gr.Markdown("# Diagrama de Aportes de Participantes")
kdis = gr.Radio(choices=[0.5, 1.0, 2.0, 3.0], label="Selecciona Expansi贸n de Grafo: ")
with gr.Row():
gr.Markdown("## Red de Aportes:")
graph_output = gr.Image("graph.png", label="Red de Aportes") # Evita llamada prematura
with gr.Row():
nombre = gr.Dropdown(choices=students, label="Nombre del Estudiante")
with gr.Row():
texto = gr.Textbox(label="Pregunta del Docente:")
submit_button = gr.Button("Agregar Aporte")
submit_button.click(
fn=agregar_aporte,
inputs=[nombre, texto, kdis],
outputs=[graph_output]
)
reload_button = gr.Button("馃攧 Recargar Diagrama desde Repositorio")
reload_button.click(
fn=reload_data,
inputs=[kdis],
outputs=[graph_output]
)
iface.launch(share=True)
if __name__ == "__main__":
iniciar_interfaz()