Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from rag_query import query_rag
|
| 3 |
+
|
| 4 |
+
# Custom CSS for styling
|
| 5 |
+
st.markdown("""
|
| 6 |
+
<style>
|
| 7 |
+
.main {background-color: #f5f5f5;}
|
| 8 |
+
.stTextInput > div > div > input {border: 2px solid #4CAF50; border-radius: 5px;}
|
| 9 |
+
.stButton > button {background-color: #4CAF50; color: white; border-radius: 5px;}
|
| 10 |
+
.stSelectbox > div > div > select {border: 2px solid #4CAF50; border-radius: 5px;}
|
| 11 |
+
</style>
|
| 12 |
+
""", unsafe_allow_html=True)
|
| 13 |
+
|
| 14 |
+
# Header with logo and text
|
| 15 |
+
col1, col2 = st.columns([1, 4])
|
| 16 |
+
with col1:
|
| 17 |
+
st.image("UMC_Logo.png", width=100) # Logo file in root directory
|
| 18 |
+
with col2:
|
| 19 |
+
st.markdown("**United Methodist Communications**", unsafe_allow_html=True)
|
| 20 |
+
st.title("United Methodist Church Discipline Assistant")
|
| 21 |
+
st.write("Ask questions about The Book of Discipline 2020-2024, including its Constitution and history!")
|
| 22 |
+
|
| 23 |
+
# Password check
|
| 24 |
+
password = st.text_input("Enter password:", type="password", key="password")
|
| 25 |
+
if password != "umcom2025": # Set your password here (e.g., "umc2024")
|
| 26 |
+
st.error("Incorrect password. Please try again.")
|
| 27 |
+
st.stop()
|
| 28 |
+
|
| 29 |
+
# Interactive input with sample questions
|
| 30 |
+
sample_questions = [
|
| 31 |
+
"Can you give me the history of United Methodist Church",
|
| 32 |
+
"What does the Constitution say about inclusiveness?",
|
| 33 |
+
"Tell me about Our Doctrinal Standards and General Rules."
|
| 34 |
+
]
|
| 35 |
+
query = st.selectbox("Pick a question or type your own:", [""] + sample_questions, key="query_select") or st.text_input("Your question:", key="query_input")
|
| 36 |
+
|
| 37 |
+
# Process query and display response
|
| 38 |
+
if st.button("Submit"):
|
| 39 |
+
with st.spinner("Fetching response..."):
|
| 40 |
+
response = query_rag(query)
|
| 41 |
+
st.markdown(response)
|
| 42 |
+
|
| 43 |
+
# Sidebar with instructions
|
| 44 |
+
st.sidebar.header("Instructions")
|
| 45 |
+
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.")
|
| 46 |
+
st.sidebar.header("About")
|
| 47 |
+
st.sidebar.write("Powered by United Methodist Communications.")
|