Spaces:
No application file
No application file
| from transformers import pipeline | |
| import gradio as gr | |
| generator = pipeline( | |
| "text2text-generation", | |
| model="google/flan-t5-small" | |
| ) | |
| def career_advice(age, academic_level, interests, needs_income): | |
| prompt = f""" | |
| You are an expert career advisor. A student has the following data: | |
| - Age: {age} | |
| - Academic level: {academic_level} | |
| - Interests: {interests} | |
| - Needs income: {needs_income} | |
| Give a clear, realistic, and motivating recommendation about whether the student should: | |
| - Continue studying | |
| - Do vocational training (FP) | |
| - Start working | |
| Explain the reasoning behind your recommendation. | |
| """ | |
| result = generator(prompt, max_length=200) | |
| return result[0]['generated_text'] | |
| with gr.Blocks(title="Asesor de Carrera Profesional") as demo: | |
| gr.Markdown( | |
| """ | |
| #Asesor de Carrera Profesional con IA | |
| Bienvenido al asesor de carrera basado en el modelo **FLAN-T5**. | |
| Introduce tus datos para recibir una recomendación personalizada sobre si deberías **continuar estudiando**, | |
| hacer **Formación Profesional (FP)** o **comenzar a trabajar**. | |
| """ | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| gr.Markdown("## 📝 Datos del Estudiante") | |
| age_input = gr.Number(label="Edad", minimum=15, maximum=60, step=1) | |
| academic_input = gr.Textbox(label="Nivel Académico (Ej: ESO, Bachillerato, Grado Universitario, etc.)", placeholder="Ej: Bachillerato de Ciencias") | |
| interests_input = gr.Textbox(label="Intereses (Palabras clave)", placeholder="Ej: Tecnología, Diseño Gráfico, Cocina, Viajes") | |
| income_input = gr.Dropdown(choices=["Sí", "No"], label="¿Necesitas generar ingresos inmediatamente?") | |
| run_button = gr.Button("Obtener Recomendación ✨", variant="primary") | |
| with gr.Column(scale=2): | |
| gr.Markdown("## 💡 Recomendación Personalizada") | |
| output_textbox = gr.Textbox(label="Recomendación del Experto", lines=10, interactive=False) | |
| run_button.click( | |
| fn=career_advice, | |
| inputs=[age_input, academic_input, interests_input, income_input], | |
| outputs=output_textbox | |
| ) | |
| gr.Examples( | |
| examples=[ | |
| [18, "High School Diploma", "Web design, programming", "No"], | |
| [25, "University Degree (Incomplete)", "Project management, sales", "Yes"], | |
| [16, "Compulsory Secondary Education (ESO)", "Mechanics, vehicle repair", "No"] | |
| ], | |
| inputs=[age_input, academic_input, interests_input, income_input] | |
| ) | |
| demo.launch() |