Update src/streamlit_app.py
Browse files- 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 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
| 228 |
|
| 229 |
if st.button("Process[CSV]"):
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
| 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"):
|