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: 68px; /* Increased font size for better proportionality */ | |
| font-weight: bold; | |
| display: flex; | |
| align-items: center; /* Vertically center the text */ | |
| height: 100%; /* Match the height of the logo column */ | |
| margin: 0; /* Remove default margins */ | |
| padding-left: 10px; /* Small padding for spacing */ | |
| } | |
| .logo-container { | |
| display: flex; | |
| align-items: center; /* Vertically center the logo */ | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Initialize session state for password | |
| if "authenticated" not in st.session_state: | |
| st.session_state.authenticated = False | |
| # Header with logo and text | |
| if st.session_state.authenticated: | |
| col1, col2 = st.columns([1, 3]) | |
| with col1: | |
| st.markdown('<div class="logo-container">', unsafe_allow_html=True) | |
| st.image("UMC_Logo.png", width=400) # Increased logo size | |
| st.markdown('</div>', unsafe_allow_html=True) | |
| with col2: | |
| st.markdown('<p class="umc-header">United Methodist Communications</p>', unsafe_allow_html=True) | |
| st.title("United Methodist Church Discipline Assistant") | |
| st.write("Ask questions about The Book of Discipline 2020-2024, including its Constitution and history!") | |
| # 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) | |
| # 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 == "umc2024": # Set your password here | |
| st.session_state.authenticated = True | |
| st.rerun() # Refresh to show main app | |
| else: | |
| st.error("Incorrect password. Please try again.") | |
| # Sidebar with instructions | |
| st.sidebar.header("Instructions") | |
| st.sidebar.write("Enter a question about The United Methodist Church's Book of Discipline 2020-2024. 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.") |