Spaces:
Sleeping
Sleeping
Rename option1_app.py to option2_app.py
Browse files
option1_app.py → option2_app.py
RENAMED
|
@@ -4,9 +4,24 @@ from rag_query import query_rag, vector_store # Added vector_store import
|
|
| 4 |
# Custom CSS for styling
|
| 5 |
st.markdown("""
|
| 6 |
<style>
|
| 7 |
-
|
| 8 |
-
.
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
.stButton > button {
|
| 11 |
background-color: #333333; /* Dark grey */
|
| 12 |
color: white;
|
|
@@ -14,6 +29,7 @@ st.markdown("""
|
|
| 14 |
border: none;
|
| 15 |
padding: 10px 20px;
|
| 16 |
font-size: 16px;
|
|
|
|
| 17 |
}
|
| 18 |
.stButton > button:hover {
|
| 19 |
background-color: #4CAF50; /* Green on hover */
|
|
@@ -26,6 +42,7 @@ st.markdown("""
|
|
| 26 |
border: none;
|
| 27 |
padding: 10px 20px;
|
| 28 |
font-size: 16px;
|
|
|
|
| 29 |
}
|
| 30 |
.new-chat-button > button:hover {
|
| 31 |
background-color: #CC0000; /* Darker red on hover */
|
|
@@ -44,6 +61,55 @@ st.markdown("""
|
|
| 44 |
margin-top: 20px;
|
| 45 |
margin-bottom: 20px;
|
| 46 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</style>
|
| 48 |
""", unsafe_allow_html=True)
|
| 49 |
|
|
@@ -114,7 +180,7 @@ if st.session_state.authenticated:
|
|
| 114 |
if st.button("Submit"):
|
| 115 |
with st.spinner("UMC AI Bot is thinking..."):
|
| 116 |
# Retrieve chunks and response
|
| 117 |
-
results = vector_store.similarity_search(query, k=
|
| 118 |
st.session_state.retrieved_chunks = results # Store retrieved chunks
|
| 119 |
response = query_rag(query)
|
| 120 |
st.session_state.query_history.append((query, response)) # Store query and response
|
|
@@ -123,7 +189,8 @@ if st.session_state.authenticated:
|
|
| 123 |
|
| 124 |
# Display query history
|
| 125 |
for i, (q, r) in enumerate(st.session_state.query_history):
|
| 126 |
-
st.markdown(
|
|
|
|
| 127 |
st.markdown(r)
|
| 128 |
# Display retrieved chunks in a dropdown
|
| 129 |
if st.session_state.retrieved_chunks:
|
|
@@ -140,6 +207,7 @@ if st.session_state.authenticated:
|
|
| 140 |
if chunk.metadata["paragraph_number"]:
|
| 141 |
st.markdown(f"**Paragraph {chunk.metadata['paragraph_number']}:** {chunk.metadata['paragraph_title']}")
|
| 142 |
st.markdown(f"**Text:** {chunk.page_content}")
|
|
|
|
| 143 |
st.markdown("---")
|
| 144 |
|
| 145 |
# New prompt window with sample questions
|
|
@@ -167,5 +235,16 @@ st.sidebar.markdown('<p class="umc-header">United Methodist Communications</p>',
|
|
| 167 |
st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) # Add space
|
| 168 |
st.sidebar.header("Instructions")
|
| 169 |
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.")
|
| 170 |
-
st.sidebar.header("About")
|
| 171 |
-
st.sidebar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Custom CSS for styling
|
| 5 |
st.markdown("""
|
| 6 |
<style>
|
| 7 |
+
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');
|
| 8 |
+
.main {
|
| 9 |
+
background-color: #f5f5f5;
|
| 10 |
+
font-family: 'Roboto', sans-serif;
|
| 11 |
+
}
|
| 12 |
+
.stTextInput > div > div > input {border: 2px solid #C8102E;
|
| 13 |
+
border-radius: 5px;
|
| 14 |
+
background-color: #FFFFFF;
|
| 15 |
+
padding: 10px;
|
| 16 |
+
font-size: 16px
|
| 17 |
+
}
|
| 18 |
+
.stSelectbox > div > div > select {
|
| 19 |
+
border: 2px solid #C8102E;
|
| 20 |
+
border-radius: 5px;
|
| 21 |
+
background-color: #FFFFFF;
|
| 22 |
+
padding: 10px;
|
| 23 |
+
font-size: 16px;
|
| 24 |
+
}
|
| 25 |
.stButton > button {
|
| 26 |
background-color: #333333; /* Dark grey */
|
| 27 |
color: white;
|
|
|
|
| 29 |
border: none;
|
| 30 |
padding: 10px 20px;
|
| 31 |
font-size: 16px;
|
| 32 |
+
transition: background-color 0.3s;
|
| 33 |
}
|
| 34 |
.stButton > button:hover {
|
| 35 |
background-color: #4CAF50; /* Green on hover */
|
|
|
|
| 42 |
border: none;
|
| 43 |
padding: 10px 20px;
|
| 44 |
font-size: 16px;
|
| 45 |
+
transition: background-color 0.3s;
|
| 46 |
}
|
| 47 |
.new-chat-button > button:hover {
|
| 48 |
background-color: #CC0000; /* Darker red on hover */
|
|
|
|
| 61 |
margin-top: 20px;
|
| 62 |
margin-bottom: 20px;
|
| 63 |
}
|
| 64 |
+
.query-card {
|
| 65 |
+
background-color: #FFFFFF;
|
| 66 |
+
border-radius: 10px;
|
| 67 |
+
padding: 15px;
|
| 68 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 69 |
+
margin-bottom: 20px;
|
| 70 |
+
}
|
| 71 |
+
.query-title {
|
| 72 |
+
font-size: 18px;
|
| 73 |
+
font-weight: bold;
|
| 74 |
+
color: #333333;
|
| 75 |
+
border-bottom: 2px solid #C8102E;
|
| 76 |
+
padding-bottom: 5px;
|
| 77 |
+
margin-bottom: 10px;
|
| 78 |
+
}
|
| 79 |
+
.sidebar {
|
| 80 |
+
background-color: #E8ECEF;
|
| 81 |
+
padding: 20px;
|
| 82 |
+
}
|
| 83 |
+
.divider {
|
| 84 |
+
border-top: 1px solid #C8102E;
|
| 85 |
+
margin: 10px 0;
|
| 86 |
+
}
|
| 87 |
+
.footer {
|
| 88 |
+
background-color: #E8ECEF;
|
| 89 |
+
padding: 10px;
|
| 90 |
+
text-align: center;
|
| 91 |
+
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
|
| 92 |
+
margin-top: 20px;
|
| 93 |
+
font-size: 14px;
|
| 94 |
+
color: #333333;
|
| 95 |
+
}
|
| 96 |
+
.footer a {
|
| 97 |
+
color: #C8102E;
|
| 98 |
+
text-decoration: none;
|
| 99 |
+
}
|
| 100 |
+
.footer a:hover {
|
| 101 |
+
text-decoration: underline;
|
| 102 |
+
}
|
| 103 |
+
@media (max-width: 768px) {
|
| 104 |
+
.header-banner {
|
| 105 |
+
flex-direction: column;
|
| 106 |
+
align-items: flex-start;
|
| 107 |
+
}
|
| 108 |
+
.header-text {
|
| 109 |
+
font-size: 20px;
|
| 110 |
+
margin-top: 10px;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
</style>
|
| 114 |
""", unsafe_allow_html=True)
|
| 115 |
|
|
|
|
| 180 |
if st.button("Submit"):
|
| 181 |
with st.spinner("UMC AI Bot is thinking..."):
|
| 182 |
# Retrieve chunks and response
|
| 183 |
+
results = vector_store.similarity_search(query, k=8) # Assuming vector_store is accessible
|
| 184 |
st.session_state.retrieved_chunks = results # Store retrieved chunks
|
| 185 |
response = query_rag(query)
|
| 186 |
st.session_state.query_history.append((query, response)) # Store query and response
|
|
|
|
| 189 |
|
| 190 |
# Display query history
|
| 191 |
for i, (q, r) in enumerate(st.session_state.query_history):
|
| 192 |
+
st.markdown('<div class="query-card">', unsafe_allow_html=True)
|
| 193 |
+
st.markdown(f'<div class="query-title">Query {i+1}: {q}</div>', unsafe_allow_html=True)
|
| 194 |
st.markdown(r)
|
| 195 |
# Display retrieved chunks in a dropdown
|
| 196 |
if st.session_state.retrieved_chunks:
|
|
|
|
| 207 |
if chunk.metadata["paragraph_number"]:
|
| 208 |
st.markdown(f"**Paragraph {chunk.metadata['paragraph_number']}:** {chunk.metadata['paragraph_title']}")
|
| 209 |
st.markdown(f"**Text:** {chunk.page_content}")
|
| 210 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 211 |
st.markdown("---")
|
| 212 |
|
| 213 |
# New prompt window with sample questions
|
|
|
|
| 235 |
st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) # Add space
|
| 236 |
st.sidebar.header("Instructions")
|
| 237 |
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.")
|
| 238 |
+
st.sidebar.header("About This AI Bot")
|
| 239 |
+
st.sidebar.markdown("""
|
| 240 |
+
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.
|
| 241 |
+
**How It Can Help:**
|
| 242 |
+
- **Historical Insights:** Learn about the UMC’s origins, key figures like John Wesley, and its global expansion.
|
| 243 |
+
- **Constitutional Guidance:** Understand the UMC’s governance, inclusiveness, and social principles.
|
| 244 |
+
- **Practical Applications:** Explore guidelines for local church organization, Special Sundays, and community outreach.
|
| 245 |
+
- **Social and Ethical Stances:** Discover the UMC’s positions on issues like marriage, social justice, and more.
|
| 246 |
+
**Limitations:**
|
| 247 |
+
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.
|
| 248 |
+
""")
|
| 249 |
+
# Footer
|
| 250 |
+
st.markdown('<div class="footer">Powered by <a href="https://www.eksource.com/" target="_blank">ekSource Technologies, Inc</a></div>', unsafe_allow_html=True)
|