import gradio as gr def mock_analyze(text): if not text.strip(): return {"Error": "Please enter a journal entry."} # Simulate realistic output based on input if "sad" in text.lower() or "hurt" in text.lower() or "lonely" in text.lower(): return { "Prediction": "Emotion: Sadness", "Confidence": 0.92, "Suggested Action": "Student may be feeling isolated. Consider a 1:1 check-in or peer connection activity." } elif "happy" in text.lower() or "joy" in text.lower() or "excited" in text.lower(): return { "Prediction": "Emotion: Joy", "Confidence": 0.87, "Suggested Action": "Positive engagement! Reinforce with praise or group recognition." } elif "fixed" in text.lower() or "can't" in text.lower() or "always fail" in text.lower(): return { "Prediction": "Mindset: Fixed", "Confidence": 0.85, "Suggested Action": "Introduce growth-mindset stories or challenges to reframe struggle as learning." } else: return { "Prediction": "Risk: Low", "Confidence": 0.78, "Suggested Action": "No immediate concern. Continue monitoring through weekly check-ins." } gr.Interface( fn=mock_analyze, inputs=gr.Textbox( lines=5, placeholder="Example: I felt sad today because my friend didn’t talk to me." ), outputs="json", title="🧠 MindSpark-1.0 (Demo)", description=""" Ethical AI for student emotional insight — built by Ciphemic.
This is a simulation of the offline AI that runs on Chromebooks in schools.
🔒 No data is collected. No internet required in production. """ ).launch()