Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def mock_analyze(text):
|
| 4 |
+
if not text.strip():
|
| 5 |
+
return {"Error": "Please enter a journal entry."}
|
| 6 |
+
|
| 7 |
+
# Simulate realistic output based on input
|
| 8 |
+
if "sad" in text.lower() or "hurt" in text.lower() or "lonely" in text.lower():
|
| 9 |
+
return {
|
| 10 |
+
"Prediction": "Emotion: Sadness",
|
| 11 |
+
"Confidence": 0.92,
|
| 12 |
+
"Suggested Action": "Student may be feeling isolated. Consider a 1:1 check-in or peer connection activity."
|
| 13 |
+
}
|
| 14 |
+
elif "happy" in text.lower() or "joy" in text.lower() or "excited" in text.lower():
|
| 15 |
+
return {
|
| 16 |
+
"Prediction": "Emotion: Joy",
|
| 17 |
+
"Confidence": 0.87,
|
| 18 |
+
"Suggested Action": "Positive engagement! Reinforce with praise or group recognition."
|
| 19 |
+
}
|
| 20 |
+
elif "fixed" in text.lower() or "can't" in text.lower() or "always fail" in text.lower():
|
| 21 |
+
return {
|
| 22 |
+
"Prediction": "Mindset: Fixed",
|
| 23 |
+
"Confidence": 0.85,
|
| 24 |
+
"Suggested Action": "Introduce growth-mindset stories or challenges to reframe struggle as learning."
|
| 25 |
+
}
|
| 26 |
+
else:
|
| 27 |
+
return {
|
| 28 |
+
"Prediction": "Risk: Low",
|
| 29 |
+
"Confidence": 0.78,
|
| 30 |
+
"Suggested Action": "No immediate concern. Continue monitoring through weekly check-ins."
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
gr.Interface(
|
| 34 |
+
fn=mock_analyze,
|
| 35 |
+
inputs=gr.Textbox(
|
| 36 |
+
lines=5,
|
| 37 |
+
placeholder="Example: I felt sad today because my friend didn’t talk to me."
|
| 38 |
+
),
|
| 39 |
+
outputs="json",
|
| 40 |
+
title="🧠 MindSpark-1.0 (Demo)",
|
| 41 |
+
description="""
|
| 42 |
+
<strong>Ethical AI for student emotional insight</strong> — built by <a href='https://ciphemic.com' target='_blank'>Ciphemic</a>.<br>
|
| 43 |
+
This is a <i>simulation</i> of the offline AI that runs on Chromebooks in schools.<br>
|
| 44 |
+
🔒 No data is collected. No internet required in production.
|
| 45 |
+
"""
|
| 46 |
+
).launch()
|