import streamlit as st import random import time from streamlit.components.v1 import html # Set page config with light purple theme st.set_page_config( page_title="Emotion Mirror Chatbot", page_icon="š", layout="centered", initial_sidebar_state="collapsed" ) # Custom CSS for enhanced light purple theme st.markdown(""" """, unsafe_allow_html=True) # Emotion databases POSITIVE_WORDS = {"happy", "awesome", "great", "joy", "excited", "good", "wonderful", "fantastic", "amazing", "yay", "ecstatic"} NEGATIVE_WORDS = {"sad", "depressed", "angry", "cry", "lonely", "bad", "terrible", "awful", "miserable", "upset", "grief"} LOVE_WORDS = {"love", "heart", "adore", "crush", "romance", "affection", "passion"} HELP_RESPONSES = [ "Would you like to talk about it? š¬", "I'm here to listen whenever you need š", "Want some uplifting quotes? š", "Would a virtual hug help? š¤", "Let's focus on something positive š", "Remember: this too shall pass š¤ļø" ] # ASCII Art Library FACES = { "happy": r""" āāāāāāāāāāāāāā š AWESOME DAY! āāāāāāāāāāāāāā """, "sad": r""" āāāāāāāāāāāāāā š¢ TOUGH TIMES? āāāāāāāāāāāāāā """, "neutral": r""" āāāāāāāāāāāāāā š HELLO THERE āāāāāāāāāāāāāā """, "love": r""" āāāāāāāāāāāāāā š LOVELY FEELING! āāāāāāāāāāāāāā """, "angry": r""" āāāāāāāāāāāāāā š TAKE A DEEP BREATH āāāāāāāāāāāāāā """ } # Confetti effect using JavaScript def confetti_effect(): confetti_js = """ """ html(confetti_js) # Emotion detection function def detect_emotion(text): text = text.lower() if any(word in text for word in POSITIVE_WORDS): return "happy" elif any(word in text for word in NEGATIVE_WORDS): return "sad" elif any(word in text for word in LOVE_WORDS): return "love" elif "angry" in text or "mad" in text or "furious" in text: return "angry" return "neutral" # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [] st.session_state.current_emotion = "neutral" # Header with title and description st.markdown('