Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from rag_query import query_rag | |
| # Custom CSS for styling | |
| st.markdown(""" | |
| <style> | |
| .main {background-color: #f5f5f5;} | |
| .stTextInput > div > div > input {border: 2px solid #4CAF50; border-radius: 5px;} | |
| .stSelectbox > div > div > select {border: 2px solid #4CAF50; border-radius: 5px;} | |
| .stButton > button { | |
| background-color: #333333; /* Dark grey */ | |
| color: white; | |
| border-radius: 5px; | |
| border: none; | |
| padding: 10px 20px; | |
| font-size: 16px; | |
| } | |
| .stButton > button:hover { | |
| background-color: #4CAF50; /* Green on hover */ | |
| color: white; | |
| } | |
| .umc-header { | |
| font-size: 24px; /* Adjusted font size for sidebar */ | |
| font-weight: bold; | |
| margin-top: 10px; /* Space between logo and text */ | |
| margin-bottom: 20px; /* Space before Instructions */ | |
| } | |
| .spacer { | |
| margin-top: 30px; /* Space between text and Instructions */ | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Initialize session state for password | |
| if "authenticated" not in st.session_state: | |
| st.session_state.authenticated = False | |
| # Main app title (shown on all screens) | |
| st.title("United Methodist Church Discipline Assistant") | |
| st.write("Ask questions about The Book of Discipline 2020-2024!") | |
| # Password form (shown only if not authenticated) | |
| if not st.session_state.authenticated: | |
| with st.form(key="password_form"): | |
| password = st.text_input("Enter password:", type="password", key="password") | |
| submit_password = st.form_submit_button("Login") | |
| if submit_password: | |
| if password == "umc2025": # Password as set | |
| st.session_state.authenticated = True | |
| st.rerun() # Refresh to show main app | |
| else: | |
| st.error("Incorrect password. Please try again.") | |
| # Main app content (shown only if authenticated) | |
| if st.session_state.authenticated: | |
| # Interactive input with sample questions | |
| sample_questions = [ | |
| "Can you tell me the history of United Methodist Church", | |
| "What does the Constitution say about inclusiveness?", | |
| "Tell me about John Wesley." | |
| ] | |
| query = st.selectbox("Pick a question or type your own:", [""] + sample_questions, key="query_select") or st.text_input("Your question:", key="query_input") | |
| # Process query and display response | |
| if st.button("Submit"): | |
| with st.spinner("Fetching response..."): | |
| response = query_rag(query) | |
| st.markdown(response) | |
| # Sidebar with logo, text, and instructions (always shown) | |
| st.sidebar.image("UMC_Logo.png", width=200) # Adjusted logo size for sidebar | |
| st.sidebar.markdown('<p class="umc-header">United Methodist Communications</p>', unsafe_allow_html=True) | |
| st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) # Add space | |
| st.sidebar.header("Instructions") | |
| st.sidebar.write("Enter a question about The United Methodist Church's Book of Discipline. The assistant will retrieve relevant sections and explain them in simple language, citing parts, paragraphs, and titles as needed.") | |
| st.sidebar.header("About") | |
| st.sidebar.write("Powered by United Methodist Communications.") |