🧠 MindLens — Your Reflection Companion
", unsafe_allow_html=True)
st.markdown("Write how you're feeling and get a short insight, gentle reflection prompts and micro-actions.
", unsafe_allow_html=True)
with st.form("reflection_form"):
text = st.text_area("💬 Write your thoughts:", height=220, placeholder="Example: I've been working hard and feel tired but also proud...", key="input_text")
submitted = st.form_submit_button("✨ Analyze My Thoughts")
# small note about model availability
if engine.classifier is None and engine.zero_shot is None:
st.warning("Model classifiers not found — MindLens will use lightweight heuristics. (Upload a fine-tuned model for better accuracy.)")
# Analyze when user submits
if submitted:
# ensure text not empty
if not text or not text.strip():
st.error("Please write a few sentences so MindLens can analyze them.")
else:
with st.spinner("Analyzing — one moment..."):
result = engine.analyze(text)
# Render output in a clean white card
st.markdown("", unsafe_allow_html=True)
st.markdown("", unsafe_allow_html=True)
st.markdown(f"
", unsafe_allow_html=True) st.markdown(f"", unsafe_allow_html=True)
# Reflection prompts
st.markdown("
", unsafe_allow_html=True) #
# helpful note
st.markdown("🔮
Summary
{result.get('summary','')}
", unsafe_allow_html=True)
mood = result.get("mood", "neutral")
mood_conf = result.get("mood_confidence", 0.0)
balance = result.get("balance_score", "N/A")
st.markdown("", unsafe_allow_html=True) st.markdown(f"
Mood: {mood.title()}
"
f"Confidence: {round(mood_conf*100,1) if isinstance(mood_conf,float) else mood_conf}%
"
f"Balance Score: {balance}/100
", unsafe_allow_html=True)
st.markdown("### 🪞 Reflection prompts")
for p in result.get("reflection_prompts", []):
st.markdown(f"- {p}")
st.markdown("### 🌱 Micro-actions")
for a in result.get("micro_actions", []):
st.markdown(f"- {a}")
st.markdown("### 💡 Practical suggestions (concise)")
for s in result.get("suggestions", []):
st.markdown(f"- {s}")
st.markdown("
Note: states like happines/joy may show as Optimist/neutral.
", unsafe_allow_html=True)