ryujiho commited on
Commit
ebd322f
ยท
verified ยท
1 Parent(s): 5dc9bd9

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +43 -40
src/streamlit_app.py CHANGED
@@ -205,48 +205,51 @@ def main():
205
 
206
  ################## TXT, CSV ๋ฒ„ํŠผ ๊ตฌํ˜„
207
  if st.button("Process[TXT]"):
208
- with st.spinner("Processing"):
209
- doc_list = []
210
- if not docs:
211
- st.error("๋จผ์ € TXT ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.")
212
- st.stop()
213
-
214
- for file in docs:
215
- print('file - type : ', file.type)
216
- if file.type == 'text/plain':
217
- doc_list.extend(get_text_file(file))
218
- else:
219
- st.error(f"{file.name} ์€(๋Š”) TXT ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค.")
220
-
221
- if not doc_list:
222
- st.error("์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•œ TXT ๋ฌธ์„œ๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.")
223
- st.stop()
224
-
225
- text_chunks = get_text_chunks(doc_list)
226
- vectorstore = get_vectorstore(text_chunks)
227
- st.session_state.conversation = get_conversation_chain(vectorstore)
 
 
228
 
229
  if st.button("Process[CSV]"):
230
- with st.spinner("Processing"):
231
- doc_list = []
232
- if not docs:
233
- st.error("๋จผ์ € CSV ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.")
234
- st.stop()
235
-
236
- for file in docs:
237
- print('file - type : ', file.type)
238
- if file.type in ['text/csv', 'application/vnd.ms-excel']:
239
- doc_list.extend(get_csv_file(file))
240
- else:
241
- st.error(f"{file.name} ์€(๋Š”) CSV ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค.")
242
-
243
- if not doc_list:
244
- st.error("์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•œ CSV ๋ฌธ์„œ๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.")
245
- st.stop()
246
-
247
- text_chunks = get_text_chunks(doc_list)
248
- vectorstore = get_vectorstore(text_chunks)
249
- st.session_state.conversation = get_conversation_chain(vectorstore)
 
250
 
251
  if st.button("Process[JSON]"):
252
  with st.spinner("Processing"):
 
205
 
206
  ################## TXT, CSV ๋ฒ„ํŠผ ๊ตฌํ˜„
207
  if st.button("Process[TXT]"):
208
+ with st.spinner("Processing"):
209
+ doc_list = []
210
+
211
+ if not docs:
212
+ st.error("๋จผ์ € TXT ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.")
213
+ st.stop()
214
+
215
+ for file in docs:
216
+ print('file - type : ', file.type)
217
+ # ๊ธฐ๋ณธ MIME: text/plain
218
+ if file.type == 'text/plain':
219
+ doc_list.extend(get_text_file(file))
220
+ else:
221
+ st.error(f"{file.name} ์€(๋Š”) TXT ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค.")
222
+
223
+ if not doc_list:
224
+ st.error("์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•œ TXT ๋ฌธ์„œ๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.")
225
+ st.stop()
226
+
227
+ text_chunks = get_text_chunks(doc_list)
228
+ vectorstore = get_vectorstore(text_chunks)
229
+ st.session_state.conversation = get_conversation_chain(vectorstore)
230
 
231
  if st.button("Process[CSV]"):
232
+ with st.spinner("Processing"):
233
+ doc_list = []
234
+
235
+ if not docs:
236
+ st.error("๋จผ์ € CSV ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.")
237
+ st.stop()
238
+
239
+ for file in docs:
240
+ print('file - type : ', file.type)
241
+ if file.type in ['text/csv', 'application/vnd.ms-excel']:
242
+ doc_list.extend(get_csv_file(file))
243
+ else:
244
+ st.error(f"{file.name} ์€(๋Š”) CSV ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค.")
245
+
246
+ if not doc_list:
247
+ st.error("์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•œ CSV ๋ฌธ์„œ๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.")
248
+ st.stop()
249
+
250
+ text_chunks = get_text_chunks(doc_list)
251
+ vectorstore = get_vectorstore(text_chunks)
252
+ st.session_state.conversation = get_conversation_chain(vectorstore)
253
 
254
  if st.button("Process[JSON]"):
255
  with st.spinner("Processing"):