Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -176,22 +176,20 @@ def main():
|
|
176 |
st.text_area(f"Source {i + 1} - Page {source['page']}", value=source["content"], height=100)
|
177 |
|
178 |
with st.form(key="question_form"):
|
179 |
-
message = st.text_input("Ask a question", key="
|
180 |
submit_button = st.form_submit_button(label="Submit")
|
181 |
|
182 |
if submit_button:
|
183 |
with st.spinner("Generating response..."):
|
184 |
-
#
|
185 |
-
qa_chain, chat_history, response_answer, sources = conversation(
|
186 |
-
st.session_state['qa_chain'], message, st.session_state['chat_history']
|
187 |
-
)
|
188 |
st.session_state['qa_chain'] = qa_chain
|
189 |
st.session_state['chat_history'] = chat_history
|
190 |
st.session_state['sources'] = sources
|
191 |
|
192 |
-
# Clear the
|
193 |
-
|
194 |
-
st.
|
195 |
|
196 |
if __name__ == "__main__":
|
197 |
main()
|
|
|
176 |
st.text_area(f"Source {i + 1} - Page {source['page']}", value=source["content"], height=100)
|
177 |
|
178 |
with st.form(key="question_form"):
|
179 |
+
message = st.text_input("Ask a question", key="message")
|
180 |
submit_button = st.form_submit_button(label="Submit")
|
181 |
|
182 |
if submit_button:
|
183 |
with st.spinner("Generating response..."):
|
184 |
+
# Call the conversation function inside the form
|
185 |
+
qa_chain, chat_history, response_answer, sources = conversation(st.session_state['qa_chain'], message, st.session_state['chat_history'])
|
|
|
|
|
186 |
st.session_state['qa_chain'] = qa_chain
|
187 |
st.session_state['chat_history'] = chat_history
|
188 |
st.session_state['sources'] = sources
|
189 |
|
190 |
+
# Clear the text input after submission
|
191 |
+
st.session_state.message = ""
|
192 |
+
st.experimental_rerun() # Force a rerun to update the UI
|
193 |
|
194 |
if __name__ == "__main__":
|
195 |
main()
|