Spaces:
Sleeping
Sleeping
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import gradio as grfrom transformers import pipeline
# Carga del modelo con autenticaci贸n autom谩tica usando token en entornoclassifier = pipeline( "text-classification", model="distilbert-base-uncased-finetuned-sst-2-english", use_auth_token=True)
notes = []
def add_note(title, content): if not content.strip(): return "Por favor ingresa contenido para la nota." result = classifier(content)[0] label = result["label"] notes.append({ "title": title or "Sin t铆tulo", "content": content, "category": label })
# Construir HTML para mostrar todas las notas display = "" for note in notes: display += f"<div style='border:1px solid #1a1a2e; background:#222; border-radius:8px; padding:10px; margin-bottom:12px;'>" display += f"<h3 style='color:#0099ff;'>{note['title']}</h3>" display += f"<p style='color:#e3eaff;'>{note['content']}</p>" display += f"<strong style='color:#0099ff;'>Categor铆a sugerida: {note['category']}</strong></div>" return display
with gr.Blocks(theme=gr.themes.Base(primary_hue="blue")) as demo: gr.Markdown("<h1 style='color:#0099ff; text-align:center;'>BATUTO_IA_NOTAS</h1>") gr.Markdown("<p style='color:#e3eaff; text-align:center;'>Bloc de notas inteligente con tema oscuro y fuentes azules.</p>") 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() submit.click(add_note, [title, content], show_notes) gr.Markdown( """ <style> body { background: #181824; } #titlebox, #contentbox, #savebtn { color: #0099ff !important; background: #23233a; border-radius: 8px; } </style> """ )
demo.launch()app.pyAdded+51