Spaces:
Runtime error
Runtime error
se0kcess commited on
Commit ยท
3e646db
1
Parent(s): b623273
"update"
Browse files
app.py
CHANGED
|
@@ -25,33 +25,25 @@ def get_pdf_text(pdf_docs):
|
|
| 25 |
# ๊ณผ์
|
| 26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 27 |
def get_text_file(txt_docs):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
txt_doc = txt_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
| 34 |
-
return txt_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 35 |
|
| 36 |
def get_csv_file(csv_docs):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
with open(temp_filepath, "wb") as f: # ์์ ํ์ผ์ ๋ฐ์ด๋๋ฆฌ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
| 50 |
-
f.write(json_docs.getvalue()) # json ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
| 51 |
-
json_loader = JSONLoader(temp_filepath) # JSONLoader๋ฅผ ์ฌ์ฉํด JSON์ ๋ก๋ํฉ๋๋ค.
|
| 52 |
-
json_doc = json_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
| 53 |
-
return json_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 54 |
-
|
| 55 |
|
| 56 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
| 57 |
def get_text_chunks(documents):
|
|
|
|
| 25 |
# ๊ณผ์
|
| 26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 27 |
def get_text_file(txt_docs):
|
| 28 |
+
text_content = ""
|
| 29 |
+
for file in txt_docs:
|
| 30 |
+
if file.type == 'text/plain':
|
| 31 |
+
text_content += TextLoader.load(file) # Using TextLoader to extract text
|
| 32 |
+
return text_content
|
|
|
|
|
|
|
| 33 |
|
| 34 |
def get_csv_file(csv_docs):
|
| 35 |
+
csv_text = ""
|
| 36 |
+
for file in csv_docs:
|
| 37 |
+
if file.type == 'text/csv':
|
| 38 |
+
csv_text += CSVLoader.load(file) # Using CSVLoader to extract text
|
| 39 |
+
return csv_text
|
| 40 |
+
|
| 41 |
+
def get_json_file(docs):
|
| 42 |
+
json_text = ""
|
| 43 |
+
for file in docs:
|
| 44 |
+
if file.type == 'application/json':
|
| 45 |
+
json_text += JSONLoader.load(file) # Using JSONLoader to extract text
|
| 46 |
+
return json_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
| 49 |
def get_text_chunks(documents):
|