Update app.py
Browse files
app.py
CHANGED
|
@@ -30,11 +30,11 @@ def get_pdf_text(pdf_docs):
|
|
| 30 |
# txt ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 31 |
def get_text_file(docs):
|
| 32 |
text_data = ""
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
return text_data
|
| 39 |
|
| 40 |
|
|
@@ -43,8 +43,9 @@ def get_csv_file(docs):
|
|
| 43 |
csv_data = ""
|
| 44 |
for doc in docs:
|
| 45 |
if doc.type == 'text/csv':
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
return csv_data
|
| 49 |
|
| 50 |
|
|
@@ -53,10 +54,12 @@ def get_json_file(docs):
|
|
| 53 |
json_data = ""
|
| 54 |
for doc in docs:
|
| 55 |
if doc.type == 'application/json':
|
| 56 |
-
|
| 57 |
-
|
|
|
|
| 58 |
return json_data
|
| 59 |
|
|
|
|
| 60 |
|
| 61 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
| 62 |
def get_text_chunks(documents):
|
|
|
|
| 30 |
# txt ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 31 |
def get_text_file(docs):
|
| 32 |
text_data = ""
|
| 33 |
+
for doc in docs:
|
| 34 |
+
if doc.type == 'text/plain':
|
| 35 |
+
text_loader = TextLoader(doc)
|
| 36 |
+
text_doc = text_loader.load()
|
| 37 |
+
text_data += text_doc if text_doc else "" # ํ
์คํธ๊ฐ ๋น์ด์์ง ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐํฉ๋๋ค.
|
| 38 |
return text_data
|
| 39 |
|
| 40 |
|
|
|
|
| 43 |
csv_data = ""
|
| 44 |
for doc in docs:
|
| 45 |
if doc.type == 'text/csv':
|
| 46 |
+
csv_loader = CSVLoader(doc)
|
| 47 |
+
csv_doc = csv_loader.load()
|
| 48 |
+
csv_data += csv_doc if csv_doc else "" # CSV ๋ฐ์ดํฐ๊ฐ ๋น์ด์์ง ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐํฉ๋๋ค.
|
| 49 |
return csv_data
|
| 50 |
|
| 51 |
|
|
|
|
| 54 |
json_data = ""
|
| 55 |
for doc in docs:
|
| 56 |
if doc.type == 'application/json':
|
| 57 |
+
json_loader = JSONLoader(doc)
|
| 58 |
+
json_doc = json_loader.load()
|
| 59 |
+
json_data += json_doc if json_doc else "" # JSON ๋ฐ์ดํฐ๊ฐ ๋น์ด์์ง ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐํฉ๋๋ค.
|
| 60 |
return json_data
|
| 61 |
|
| 62 |
+
|
| 63 |
|
| 64 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
| 65 |
def get_text_chunks(documents):
|