Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ from langchain_community.document_loaders import PyPDFLoader
|
|
5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
7 |
from langchain_huggingface import HuggingFaceEndpoint # Updated import
|
8 |
-
from langchain_huggingface import HuggingFaceEmbeddings
|
9 |
from langchain.chains import ConversationalRetrievalChain
|
10 |
from langchain.memory import ConversationBufferMemory
|
11 |
import tempfile
|
@@ -179,18 +178,12 @@ def main():
|
|
179 |
message = st.text_input("Ask a question", key="message")
|
180 |
submit_button = st.form_submit_button(label="Submit")
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
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()
|
196 |
-
|
|
|
5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
7 |
from langchain_huggingface import HuggingFaceEndpoint # Updated import
|
|
|
8 |
from langchain.chains import ConversationalRetrievalChain
|
9 |
from langchain.memory import ConversationBufferMemory
|
10 |
import tempfile
|
|
|
178 |
message = st.text_input("Ask a question", key="message")
|
179 |
submit_button = st.form_submit_button(label="Submit")
|
180 |
|
181 |
+
if submit_button:
|
182 |
+
with st.spinner("Generating response..."):
|
183 |
+
qa_chain, chat_history, response_answer, sources = conversation(st.session_state['qa_chain'], message, st.session_state['chat_history'])
|
184 |
+
st.session_state['qa_chain'] = qa_chain
|
185 |
+
st.session_state['chat_history'] = chat_history
|
186 |
+
st.session_state['sources'] = sources
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
if __name__ == "__main__":
|
189 |
+
main()
|
|