Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,34 +122,20 @@ def main():
|
|
| 122 |
"Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
|
| 123 |
if st.button("Process"):
|
| 124 |
with st.spinner("Processing"):
|
| 125 |
-
# get pdf text
|
| 126 |
doc_list = []
|
| 127 |
-
|
| 128 |
for file in docs:
|
| 129 |
-
print('file - type : ', file.type)
|
| 130 |
if file.type == 'text/plain':
|
| 131 |
-
# file is .txt
|
| 132 |
doc_list.extend(get_text_file(file))
|
| 133 |
elif file.type in ['application/octet-stream', 'application/pdf']:
|
| 134 |
-
# file is .pdf
|
| 135 |
doc_list.extend(get_pdf_text(file))
|
| 136 |
elif file.type == 'text/csv':
|
| 137 |
-
# file is .csv
|
| 138 |
doc_list.extend(get_csv_file(file))
|
| 139 |
elif file.type == 'application/json':
|
| 140 |
-
# file is .json
|
| 141 |
doc_list.extend(get_json_file(file))
|
| 142 |
|
| 143 |
-
# get the text chunks
|
| 144 |
text_chunks = get_text_chunks(doc_list)
|
| 145 |
-
|
| 146 |
-
# create vector store
|
| 147 |
vectorstore = get_vectorstore(text_chunks)
|
| 148 |
-
|
| 149 |
-
# create conversation chain
|
| 150 |
-
st.session_state.conversation = get_conversation_chain(
|
| 151 |
-
vectorstore)
|
| 152 |
-
|
| 153 |
|
| 154 |
if __name__ == '__main__':
|
| 155 |
main()
|
|
|
|
| 122 |
"Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
|
| 123 |
if st.button("Process"):
|
| 124 |
with st.spinner("Processing"):
|
|
|
|
| 125 |
doc_list = []
|
|
|
|
| 126 |
for file in docs:
|
|
|
|
| 127 |
if file.type == 'text/plain':
|
|
|
|
| 128 |
doc_list.extend(get_text_file(file))
|
| 129 |
elif file.type in ['application/octet-stream', 'application/pdf']:
|
|
|
|
| 130 |
doc_list.extend(get_pdf_text(file))
|
| 131 |
elif file.type == 'text/csv':
|
|
|
|
| 132 |
doc_list.extend(get_csv_file(file))
|
| 133 |
elif file.type == 'application/json':
|
|
|
|
| 134 |
doc_list.extend(get_json_file(file))
|
| 135 |
|
|
|
|
| 136 |
text_chunks = get_text_chunks(doc_list)
|
|
|
|
|
|
|
| 137 |
vectorstore = get_vectorstore(text_chunks)
|
| 138 |
+
st.session_state.conversation = get_conversation_chain(vectorstore)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
if __name__ == '__main__':
|
| 141 |
main()
|