File size: 1,395 Bytes
fbdec70
 
 
 
 
 
 
 
56a47a6
fbdec70
 
56a47a6
 
fbdec70
 
56a47a6
fbdec70
 
 
 
 
 
 
 
 
 
56a47a6
fbdec70
56a47a6
fbdec70
 
56a47a6
fbdec70
 
 
 
56a47a6
fbdec70
 
 
56a47a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# πŸš€ 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.** πŸ’™")