File size: 1,841 Bytes
a83deda
 
 
 
 
 
 
 
7adc39b
 
0e76a85
 
a83deda
939ac52
 
 
a83deda
939ac52
0e76a85
939ac52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
import streamlit as st
import requests
from gtts import gTTS
import base64
from io import BytesIO

st.set_page_config(page_title="NeuroPulse AI", page_icon="🧠", layout="wide")

if "review" not in st.session_state:
    st.session_state.review = ""
if "dark_mode" not in st.session_state:
    st.session_state.dark_mode = False

if st.session_state.dark_mode:
    st.markdown("""<style>body { background-color: #111; color: white; }</style>""", unsafe_allow_html=True)

with st.sidebar:
    st.title("βš™οΈ Settings")
    st.session_state.dark_mode = st.toggle("πŸŒ™ Dark Mode", value=st.session_state.dark_mode)
    api_key = st.text_input("πŸ” API Key", type="password")
    backend_url = st.text_input("🌐 Backend URL", value="http://localhost:8000")

st.title("🧠 NeuroPulse AI – Multimodal Review Analyzer")
review = st.text_area("πŸ“ Enter Review", value=st.session_state.review, height=150)

if st.button("πŸ” Analyze", use_container_width=True):
    if not api_key:
        st.error("⚠️ Please enter API key.")
    elif len(review.split()) < 10:
        st.warning("πŸ“ Minimum 10 words required.")
    else:
        with st.spinner("Processing..."):
            try:
                payload = {"text": review}
                headers = {"x-api-key": api_key}
                res = requests.post(f"{backend_url}/analyze/", json=payload, headers=headers)
                if res.status_code == 200:
                    data = res.json()
                    st.success("βœ… Analysis Successful")
                    st.info(f"πŸ“Œ Summary: {data['summary']}")
                    st.metric("πŸ“Š Sentiment", data["sentiment"]["label"])
                else:
                    st.error(f"❌ API Error: {res.status_code} - {res.text}")
            except Exception as e:
                st.error(f"🚫 Exception: {e}")