Spaces:
Sleeping
Sleeping
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}") |