import streamlit as st from rag_query import query_rag, vector_store # Custom CSS for styling st.markdown(""" """, unsafe_allow_html=True) # Initialize session state for password and query history if "authenticated" not in st.session_state: st.session_state.authenticated = False if "query_history" not in st.session_state: st.session_state.query_history = [] # Store queries and responses if "retrieved_chunks" not in st.session_state: st.session_state.retrieved_chunks = [] # Store retrieved chunks if "new_query_input" not in st.session_state: st.session_state.new_query_input = "" # Store new query input # Header banner with logo and text st.markdown('
', unsafe_allow_html=True) # Main app title (shown on all screens) st.title("United Methodist Church Discipline Assistant") # Header with description and New Chat button col1, col2 = st.columns([3, 1]) with col1: st.write("Ask questions about The Book of Discipline 2020-2024, including its Constitution and history!") with col2: if st.button("New Chat", key="new_chat"): st.session_state.query_history = [] st.session_state.retrieved_chunks = [] st.session_state.new_query_input = "" st.rerun() # 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": # 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 = [ "Who were the key figures in the early history of Methodism in America, and what did they do?", "What does the United Methodist Church Constitution say about inclusiveness and racial justice?", "What is the role of the General Conference in the United Methodist Church?", "How did the United Methodist Church form through mergers over time?", "What challenges did the UMC face during the Civil War, and how did they impact the church?", "What is the UMC’s stance on ecumenical relations according to the Constitution?", "How has the UMC addressed issues of racism throughout its history?", "What changes has the UMC faced in the 21st century, particularly around gender and sexuality?", "How has the UMC expanded globally since its formation?", "What does the UMC say about social justice through its Special Sundays?", "How does the UMC support Native American ministries according to its organizational practices?", "What is the UMC’s stance on marriage and homosexuality in the 21st century?", "How has the UMC’s position on social issues like abortion evolved over time?", "What are the Special Sundays in the UMC, and how are they celebrated?", "How does the UMC observe Heritage Sunday, and what is its significance?", "What is the role of a Certified Lay Minister in the UMC, and how do they contribute to the church?", "How does the UMC organize its local churches, particularly in terms of financial responsibilities?", "How does the UMC support community outreach through its local church organization?", "What are the UMC’s guidelines for organizing a new local church or mission congregation?" ] 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("UMCOM AI Bot is thinking..."): # Retrieve chunks and response results = vector_store.similarity_search(query, k=5) st.session_state.retrieved_chunks = results # Store retrieved chunks response = query_rag(query) st.session_state.query_history.append((query, response)) # Store query and response st.session_state.new_query_input = "" # Clear the new query input st.rerun() # Refresh to show response # Display query history for i, (q, r) in enumerate(st.session_state.query_history): st.markdown('United Methodist Communications
', unsafe_allow_html=True) st.sidebar.markdown('', unsafe_allow_html=True) # Add divider 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 This AI Bot") st.sidebar.markdown(""" ### The United Methodist Church Discipline Assistant is an AI-powered tool designed to help you explore *The Book of Discipline of The United Methodist Church 2020-2024*. Whether you're seeking insights into the UMC's history, constitutional principles, organizational structure, social justice initiatives, or worship practices, this bot provides clear, user-friendly answers with precise citations. By leveraging Retrieval-Augmented Generation (RAG), the assistant retrieves relevant sections from the Book of Discipline and explains them in simple language, making it an invaluable resource for church leaders, members, and researchers. **How It Can Help:** - **Historical Insights:** Learn about the UMC’s origins, key figures like John Wesley, and its global expansion. - **Constitutional Guidance:** Understand the UMC’s governance, inclusiveness, and social principles. - **Practical Applications:** Explore guidelines for local church organization, Special Sundays, and community outreach. - **Social and Ethical Stances:** Discover the UMC’s positions on issues like marriage, social justice, and more. **Limitations:** Please note that the dataset for this assistant covers *The Book of Discipline 2020-2024* up to Paragraph 269 on page 223. Content beyond this point, including later paragraphs or sections, is not included in the current dataset. For the most comprehensive information, refer directly to the full Book of Discipline. """) # Footer st.markdown('', unsafe_allow_html=True)