Daoneeee commited on
Commit
9b5710b
·
1 Parent(s): b57f496

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -138,20 +138,34 @@ def main():
138
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
139
  if st.button("Process"):
140
  with st.spinner("Processing"):
 
141
  doc_list = []
 
142
  for file in docs:
 
143
  if file.type == 'text/plain':
 
144
  doc_list.extend(get_text_file(file))
145
  elif file.type in ['application/octet-stream', 'application/pdf']:
 
146
  doc_list.extend(get_pdf_text(file))
147
  elif file.type == 'text/csv':
 
148
  doc_list.extend(get_csv_file(file))
149
  elif file.type == 'application/json':
 
150
  doc_list.extend(get_json_file(file))
151
 
 
152
  text_chunks = get_text_chunks(doc_list)
 
 
153
  vectorstore = get_vectorstore(text_chunks)
154
- st.session_state.conversation = get_conversation_chain(vectorstore)
 
 
 
 
155
 
156
  if __name__ == '__main__':
157
- main()
 
138
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
139
  if st.button("Process"):
140
  with st.spinner("Processing"):
141
+ # get pdf text
142
  doc_list = []
143
+
144
  for file in docs:
145
+ print('file - type : ', file.type)
146
  if file.type == 'text/plain':
147
+ # file is .txt
148
  doc_list.extend(get_text_file(file))
149
  elif file.type in ['application/octet-stream', 'application/pdf']:
150
+ # file is .pdf
151
  doc_list.extend(get_pdf_text(file))
152
  elif file.type == 'text/csv':
153
+ # file is .csv
154
  doc_list.extend(get_csv_file(file))
155
  elif file.type == 'application/json':
156
+ # file is .json
157
  doc_list.extend(get_json_file(file))
158
 
159
+ # get the text chunks
160
  text_chunks = get_text_chunks(doc_list)
161
+
162
+ # create vector store
163
  vectorstore = get_vectorstore(text_chunks)
164
+
165
+ # create conversation chain
166
+ st.session_state.conversation = get_conversation_chain(
167
+ vectorstore)
168
+
169
 
170
  if __name__ == '__main__':
171
+ main()