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.** π")
|