import gradio as gr from transformers import pipeline classifier = pipeline( "text-classification", model="distilbert-base-uncased-finetuned-sst-2-english", use_auth_token=True ) def add_note(title, content, state): if not content.strip(): return gr.update(), state, "⚠️ Escribe contenido (no vacío)." result = classifier(content)[0] label = result["label"] note = { "title": title or "Sin título", "content": content, "category": label } notes = state or [] notes.append(note) notes_html = "" for idx, n in enumerate(notes): notes_html += f'''
{n["content"]}
Categoría IA: {n["category"]}Bloc de notas inteligente con tema oscuro y fuentes azules.
") state = gr.State([]) with gr.Row(): title = gr.Textbox(label="Título", elem_id="titlebox") content = gr.Textbox(lines=4, label="Contenido de la nota", elem_id="contentbox") submit = gr.Button("Guardar nota", elem_id="savebtn") show_notes = gr.HTML(label="Tus notas") status = gr.Markdown() submit.click(add_note, [title, content, state], [show_notes, state, status]) gr.Markdown(""" """) demo.launch()