iamhere / app.py
Yuki-Chen's picture
Update app.py
56a47a6 verified
# πŸš€ Import Libraries
import streamlit as st
import requests
# βœ… API URL (Update this to your FastAPI Hugging Face Space URL)
API_URL = "https://Yuki-Chen-emochatbot.hf.space/dialogflow"
# 🎨 Streamlit UI
st.set_page_config(page_title="Lumi - I'm here for you", layout="centered")
# πŸ† Title & Description
st.title("✨ Meet Lumi - Your Companion πŸ’™")
st.markdown("πŸ’¬ *You're not alone. Lumi is here to listen and support you.*")
# πŸ“Œ User Input
user_input = st.text_area("πŸ“ Talk to Lumi:", placeholder="Tell Lumi how you're feeling today...")
# 🎯 Function to call FastAPI
def get_emotion(text):
payload = {
"queryResult": {"queryText": text},
"session": "test_session_123"
}
response = requests.post(API_URL, json=payload)
if response.status_code == 200:
return response.json().get("fulfillmentText", "Lumi is here for you. Take your time. πŸ’™")
else:
return "⚠️ API Error: Something went wrong. But Lumi is still here for you."
# 🟒 Detect Emotions Button
if st.button("πŸ’‘ Share with Lumi"):
if user_input:
result = get_emotion(user_input)
st.success(result)
else:
st.warning("πŸ’¬ Go ahead, share your thoughts with Lumi. Lumi is listening. πŸ’™")
# 🎨 Footer
st.markdown("---")
st.markdown("✨ **Lumi is always here whenever you need someone to talk to.** πŸ’™")