Update app.py
Browse files
app.py
CHANGED
@@ -152,33 +152,33 @@ def main():
|
|
152 |
docs = st.file_uploader(
|
153 |
"Upload your documents here and click on 'Process'", accept_multiple_files=True)
|
154 |
if st.button("Process"):
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
|
183 |
|
184 |
if __name__ == '__main__':
|
|
|
152 |
docs = st.file_uploader(
|
153 |
"Upload your documents here and click on 'Process'", accept_multiple_files=True)
|
154 |
if st.button("Process"):
|
155 |
+
with st.spinner("Processing"):
|
156 |
+
# get pdf text
|
157 |
+
doc_list = []
|
158 |
+
|
159 |
+
for file in docs:
|
160 |
+
print('file - type : ', file.type)
|
161 |
+
if file.type == 'text/plain':
|
162 |
+
# file is .txt
|
163 |
+
doc_list.extend(get_text_file([file]))
|
164 |
+
elif file.type in ['application/octet-stream', 'application/pdf']:
|
165 |
+
# file is .pdf
|
166 |
+
doc_list.extend(get_pdf_text(file))
|
167 |
+
elif file.type == 'text/csv':
|
168 |
+
# file is .csv
|
169 |
+
doc_list.extend(get_csv_file([file]))
|
170 |
+
elif file.type == 'application/json':
|
171 |
+
# file is .json
|
172 |
+
doc_list.extend(get_json_file([file]))
|
173 |
+
|
174 |
+
# get the text chunks
|
175 |
+
text_chunks = get_text_chunks(doc_list)
|
176 |
+
|
177 |
+
# create vector store
|
178 |
+
vectorstore = get_vectorstore(text_chunks)
|
179 |
+
|
180 |
+
# create conversation chain
|
181 |
+
st.session_state.conversation = get_conversation_chain(vectorstore)
|
182 |
|
183 |
|
184 |
if __name__ == '__main__':
|