Sambhatnagar commited on
Commit
f4b242d
·
verified ·
1 Parent(s): dd15884

Resolved the issue where the new prompt window was not showing up.

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -102,14 +102,20 @@ if st.session_state.authenticated:
102
  # New prompt window with sample questions
103
  if st.session_state.query_history: # Show only after at least one query
104
  st.markdown("### Ask Another Question")
105
- new_query = st.selectbox("Pick another question or type your own:", [""] + sample_questions, key="new_query_select") or st.text_input("Your new question:", key="new_query_input")
 
 
 
106
  if st.button("Submit New Query"):
107
- with st.spinner("Fetching response..."):
108
- results = vector_store.similarity_search(new_query, k=5)
109
- st.session_state.retrieved_chunks = results
110
- response = query_rag(new_query)
111
- st.session_state.query_history.append((new_query, response))
112
- st.rerun() # Refresh to show new response
 
 
 
113
 
114
  # Sidebar with logo, text, and instructions (always shown)
115
  st.sidebar.image("UMC_Logo.png", width=200) # Adjusted logo size for sidebar
@@ -118,4 +124,4 @@ st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) # Add
118
  st.sidebar.header("Instructions")
119
  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.")
120
  st.sidebar.header("About")
121
- st.sidebar.write("Powered by United Methodist Communications.")
 
102
  # New prompt window with sample questions
103
  if st.session_state.query_history: # Show only after at least one query
104
  st.markdown("### Ask Another Question")
105
+ selected_query = st.selectbox("Pick another question or type your own:", [""] + sample_questions, key="new_query_select")
106
+ custom_query = st.text_input("Your new question:", key="new_query_input")
107
+ # Use custom query if provided, otherwise use selected query
108
+ new_query = custom_query if custom_query else selected_query
109
  if st.button("Submit New Query"):
110
+ if new_query: # Ensure a query is provided
111
+ with st.spinner("Fetching response..."):
112
+ results = vector_store.similarity_search(new_query, k=5)
113
+ st.session_state.retrieved_chunks = results
114
+ response = query_rag(new_query)
115
+ st.session_state.query_history.append((new_query, response))
116
+ st.experimental_rerun() # Refresh to show new response
117
+ else:
118
+ st.warning("Please select a question or enter a new one.")
119
 
120
  # Sidebar with logo, text, and instructions (always shown)
121
  st.sidebar.image("UMC_Logo.png", width=200) # Adjusted logo size for sidebar
 
124
  st.sidebar.header("Instructions")
125
  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.")
126
  st.sidebar.header("About")
127
+ st.sidebar.write("Powered by ekSource Technologies, Inc")