mjpsm commited on
Commit
3fd1602
·
verified ·
1 Parent(s): 94e184f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load your fine-tuned model from Hugging Face Hub
5
+ model_name = "mjpsm/math-affirmation-model"
6
+ generator = pipeline("text2text-generation", model=model_name)
7
+
8
+ # Define the interface function
9
+ def generate_affirmation(situation):
10
+ result = generator(situation, max_length=64, clean_up_tokenization_spaces=True)[0]["generated_text"]
11
+ return result
12
+
13
+ # Gradio UI
14
+ title = "🎓 Math Affirmation Generator"
15
+ description = """
16
+ Enter a student's situation, struggle, or emotional state during a math activity.
17
+ This model, trained on Math Narrative-aligned affirmations, will respond with a positive and empathetic affirmation.
18
+
19
+ Example prompts:
20
+ - "Felt overwhelmed after missing several questions"
21
+ - "Struggled with algebra problems"
22
+ - "Lost confidence after being wrong in front of peers"
23
+ """
24
+
25
+ demo = gr.Interface(
26
+ fn=generate_affirmation,
27
+ inputs=gr.Textbox(lines=3, placeholder="Enter the student's situation here..."),
28
+ outputs=gr.Textbox(label="Affirmation"),
29
+ title=title,
30
+ description=description,
31
+ theme="soft"
32
+ )
33
+
34
+ demo.launch()