File size: 1,108 Bytes
3fd1602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
from transformers import pipeline

# Load your fine-tuned model from Hugging Face Hub
model_name = "mjpsm/math-affirmation-model"
generator = pipeline("text2text-generation", model=model_name)

# Define the interface function
def generate_affirmation(situation):
    result = generator(situation, max_length=64, clean_up_tokenization_spaces=True)[0]["generated_text"]
    return result

# Gradio UI
title = "πŸŽ“ Math Affirmation Generator"
description = """
Enter a student's situation, struggle, or emotional state during a math activity.  
This model, trained on Math Narrative-aligned affirmations, will respond with a positive and empathetic affirmation.

Example prompts:
- "Felt overwhelmed after missing several questions"
- "Struggled with algebra problems"
- "Lost confidence after being wrong in front of peers"
"""

demo = gr.Interface(
    fn=generate_affirmation,
    inputs=gr.Textbox(lines=3, placeholder="Enter the student's situation here..."),
    outputs=gr.Textbox(label="Affirmation"),
    title=title,
    description=description,
    theme="soft"
)

demo.launch()