Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -75,41 +75,39 @@ def handle_userinput(user_question):
|
|
75 |
"{{MSG}}", message.content), unsafe_allow_html=True)
|
76 |
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
st.write(css, unsafe_allow_html=True)
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
|
114 |
|
115 |
-
main()
|
|
|
75 |
"{{MSG}}", message.content), unsafe_allow_html=True)
|
76 |
|
77 |
|
78 |
+
load_dotenv()
|
79 |
+
st.set_page_config(page_title="Chat with multiple PDFs",
|
80 |
+
page_icon=":books:")
|
81 |
+
st.write(css, unsafe_allow_html=True)
|
|
|
82 |
|
83 |
+
if "conversation" not in st.session_state:
|
84 |
+
st.session_state.conversation = None
|
85 |
+
if "chat_history" not in st.session_state:
|
86 |
+
st.session_state.chat_history = None
|
87 |
|
88 |
+
st.header("Chat with multiple PDFs :books:")
|
89 |
+
user_question = st.text_input("Ask a question about your documents:")
|
90 |
+
if user_question:
|
91 |
+
handle_userinput(user_question)
|
92 |
|
93 |
+
with st.sidebar:
|
94 |
+
st.subheader("Your documents")
|
95 |
+
pdf_docs = st.file_uploader(
|
96 |
+
"Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
|
97 |
+
if st.button("Process"):
|
98 |
+
with st.spinner("Processing"):
|
99 |
+
# get pdf text
|
100 |
+
raw_text = get_pdf_text(pdf_docs)
|
101 |
|
102 |
+
# get the text chunks
|
103 |
+
text_chunks = get_text_chunks(raw_text)
|
104 |
|
105 |
+
# create vector store
|
106 |
+
vectorstore = get_vectorstore(text_chunks)
|
107 |
|
108 |
+
# create conversation chain
|
109 |
+
st.session_state.conversation = get_conversation_chain(
|
110 |
+
vectorstore)
|
111 |
|
112 |
|
113 |
|
|