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