Update app.py
Browse files
app.py
CHANGED
@@ -126,35 +126,36 @@ def main():
|
|
126 |
|
127 |
|
128 |
|
129 |
-
st.
|
130 |
-
|
|
|
131 |
|
132 |
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
# get pdf text
|
138 |
-
|
139 |
|
140 |
# get the text chunks
|
141 |
-
|
142 |
|
143 |
# create vector store
|
144 |
-
|
145 |
|
146 |
# create conversation chain
|
147 |
-
|
148 |
|
149 |
-
|
150 |
|
151 |
-
|
152 |
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
|
159 |
|
160 |
|
|
|
126 |
|
127 |
|
128 |
|
129 |
+
with st.sidebar:
|
130 |
+
st.subheader("Your documents")
|
131 |
+
pdf_docs = st.file_uploader("For Chatbot to get alive, upload your PDFs here and click on 'Process'", accept_multiple_files=True)
|
132 |
|
133 |
|
134 |
|
135 |
+
if st.button("Process"):
|
136 |
+
with st.spinner:
|
137 |
+
if pdf_docs:
|
138 |
# get pdf text
|
139 |
+
raw_text = get_pdf_text(pdf_docs)
|
140 |
|
141 |
# get the text chunks
|
142 |
+
text_chunks = get_text_chunks(raw_text)
|
143 |
|
144 |
# create vector store
|
145 |
+
vectorstore = get_vectorstore(text_chunks)
|
146 |
|
147 |
# create conversation chain
|
148 |
+
conversation = get_conversation_chain()
|
149 |
|
150 |
+
st.success("Files have been processed into a vector store.")
|
151 |
|
152 |
+
return vectorstore , conversation
|
153 |
|
154 |
|
155 |
+
|
156 |
+
st.subheader("Chat Bot")
|
157 |
+
if user_question := st.text_input("Ask a question about your documents:"):
|
158 |
+
handle_userinput(user_question, vectorstore, conversation)
|
159 |
|
160 |
|
161 |
|