# app.py import gradio as gr from transformers import pipeline # Cargar modelo ligero optimizado para instrucciones model = pipeline("text2text-generation", model="google/flan-t5-base") def answer_question(prompt): response = model(prompt, max_new_tokens=256)[0]["generated_text"] return response # Crear una interfaz tipo API con JSON app = gr.Interface( fn=answer_question, inputs=gr.Text(label="Prompt"), outputs=gr.Text(label="Respuesta"), ) app.launch()