"""
Streamlit UI Components
Contains all user interface elements and styling
"""
import streamlit as st
def apply_custom_css(theme="light"):
"""Apply custom CSS styling to the Streamlit app with theme support"""
if theme == "dark":
bg_color = "#0e1117"
card_bg = "#1e2130"
text_color = "#fafafa"
border_color = "#4a9eff"
header_color = "#4a9eff"
disclaimer_bg = "#2d2a1e"
input_bg = "#262730"
else:
bg_color = "#ffffff"
card_bg = "#f8f9fa"
text_color = "#262730"
border_color = "#1f77b4"
header_color = "#1f77b4"
disclaimer_bg = "#fff3cd"
input_bg = "#ffffff"
st.markdown(f"""
""", unsafe_allow_html=True)
def render_header():
"""Render the main header with enhanced styling"""
st.markdown('
đŠē AI Healthcare Assistant
', unsafe_allow_html=True)
# Subtitle with badges
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
st.markdown("""
Multi-Agent System for Comprehensive Health Analysis
đ¤ AI-Powered
đ Real-Time Data
⥠Fast Analysis
""", unsafe_allow_html=True)
def render_sidebar():
"""Render the sidebar with settings and information"""
with st.sidebar:
st.markdown("### âī¸ Settings")
# Initialize theme (default to light, no UI controls)
if "theme" not in st.session_state:
st.session_state.theme = "light"
st.markdown("---")
# Enhanced Info Section
with st.expander("âšī¸ How it works", expanded=False):
st.markdown("""
**Step-by-step process:**
1. đ Enter your symptoms
2. đ§ AI agents analyze your condition
3. đ Get medication recommendations
4. đŋ Discover home remedies
5. đĨ Receive diet & lifestyle advice
6. đ¨ââī¸ Find doctor recommendations
7. â ī¸ Always consult a doctor for serious conditions
""")
st.markdown("---")
# Features Section
st.markdown("### ⨠Features")
st.markdown("""
- đ§ **Symptom Analysis**
- đ **Medication Advice**
- đŋ **Home Remedies**
- đĨ **Diet & Lifestyle**
- đ¨ââī¸ **Doctor Recommendations**
""")
st.markdown("---")
# Tech Stack
st.markdown("### đ§ Built With")
st.markdown("""
- **LangGraph** - Multi-agent workflow
- **Groq LLM** - AI reasoning
- **Tavily API** - Real-time data
- **Streamlit** - Interactive UI
""")
st.markdown("---")
# Quick Stats (if results exist)
if "results" in st.session_state and st.session_state.results:
st.markdown("### đ Analysis Status")
results = st.session_state.results
completed = sum([
1 for key in ["symptom_analysis", "medication_advice",
"home_remedies", "diet_lifestyle", "doctor_recommendations"]
if results.get(key)
])
st.progress(completed / 5)
st.caption(f"{completed}/5 agents completed")
st.markdown("---")
st.caption("Š 2024 AI Healthcare Assistant")
def render_input_section():
"""Render the input section for user symptoms with enhanced styling"""
st.markdown("### đ Describe Your Symptoms")
st.markdown("Share your symptoms, health concerns, or questions below:")
user_input = st.text_area(
"Enter your symptoms:",
height=180,
placeholder="e.g., I've been experiencing headaches and fatigue for the past week. I also have a slight fever and body aches...",
label_visibility="collapsed"
)
# Helper text
if not user_input:
st.caption("đĄ Tip: Be as detailed as possible for better analysis results")
return user_input
def render_analyze_button():
"""Render the analyze button with enhanced styling"""
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
analyze_button = st.button(
"đ Analyze Symptoms",
type="primary",
use_container_width=True,
help="Click to start comprehensive health analysis"
)
return analyze_button
def render_results(results):
"""Render the analysis results all at once without dropdowns"""
if not results:
return
st.markdown("---")
st.markdown("## đ Complete Health Analysis")
# Symptom Analysis
if results.get("symptom_analysis"):
st.markdown("### đ§ Symptom Analysis")
st.markdown('', unsafe_allow_html=True)
st.markdown(results["symptom_analysis"])
st.markdown('
', unsafe_allow_html=True)
st.markdown("")
# Medication Advice
if results.get("medication_advice"):
st.markdown("### đ Medication Advice")
st.markdown('', unsafe_allow_html=True)
st.markdown(results["medication_advice"])
st.markdown('
', unsafe_allow_html=True)
st.markdown("")
# Home Remedies
if results.get("home_remedies"):
st.markdown("### đŋ Home Remedies")
st.markdown('', unsafe_allow_html=True)
st.markdown(results["home_remedies"])
st.markdown('
', unsafe_allow_html=True)
st.markdown("")
# Diet & Lifestyle
if results.get("diet_lifestyle"):
st.markdown("### đĨ Diet & Lifestyle Recommendations")
st.markdown('', unsafe_allow_html=True)
st.markdown(results["diet_lifestyle"])
st.markdown('
', unsafe_allow_html=True)
st.markdown("")
# Doctor Recommendations
if results.get("doctor_recommendations"):
st.markdown("### đ¨ââī¸ Doctor Recommendations")
st.markdown('', unsafe_allow_html=True)
st.markdown(results["doctor_recommendations"])
st.markdown('
', unsafe_allow_html=True)
st.markdown("")
# Error handling
if results.get("error"):
st.warning(f"â ī¸ Some errors occurred: {results['error']}")
def render_footer():
"""Render the footer"""
st.markdown("---")
st.caption("Š 202 AI Healthcare Assistant | Powered by LangGraph, Groq LLM, and Tavily API")