Commit ยท
30c60ed
1
Parent(s): 4dce0ce
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,33 +27,36 @@ def get_pdf_text(pdf_docs):
|
|
| 27 |
|
| 28 |
# ๊ณผ์
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
-
|
| 31 |
-
def get_text_file(
|
| 32 |
temp_dir = tempfile.TemporaryDirectory()
|
| 33 |
temp_filepath = os.path.join(temp_dir.name, text_docs.name)
|
| 34 |
with open(temp_filepath, "wb") as f:
|
| 35 |
f.write(text_docs.getvalue())
|
| 36 |
text_loader = TextLoader(temp_filepath)
|
| 37 |
-
|
| 38 |
-
return
|
| 39 |
|
| 40 |
-
|
|
|
|
| 41 |
temp_dir = tempfile.TemporaryDirectory()
|
| 42 |
temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
|
| 43 |
with open(temp_filepath, "wb") as f:
|
| 44 |
f.write(csv_docs.getvalue())
|
| 45 |
csv_loader = CSVLoader(temp_filepath)
|
| 46 |
-
|
| 47 |
-
return
|
| 48 |
|
| 49 |
-
|
|
|
|
| 50 |
temp_dir = tempfile.TemporaryDirectory()
|
| 51 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
| 52 |
with open(temp_filepath, "wb") as f:
|
| 53 |
f.write(json_docs.getvalue())
|
| 54 |
-
json_loader = JSONLoader(temp_filepath, jq_schema=
|
| 55 |
-
|
| 56 |
-
return
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
|
|
|
| 27 |
|
| 28 |
# ๊ณผ์
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
+
# ํ
์คํธ ํ์ผ๋ก๋ถํฐ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 31 |
+
def get_text_file(text_docs):
|
| 32 |
temp_dir = tempfile.TemporaryDirectory()
|
| 33 |
temp_filepath = os.path.join(temp_dir.name, text_docs.name)
|
| 34 |
with open(temp_filepath, "wb") as f:
|
| 35 |
f.write(text_docs.getvalue())
|
| 36 |
text_loader = TextLoader(temp_filepath)
|
| 37 |
+
text_docs = text_loader.load()
|
| 38 |
+
return text_docs
|
| 39 |
|
| 40 |
+
# csv ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์์
๋๋ค.
|
| 41 |
+
def get_csv_file(csv_docs):
|
| 42 |
temp_dir = tempfile.TemporaryDirectory()
|
| 43 |
temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
|
| 44 |
with open(temp_filepath, "wb") as f:
|
| 45 |
f.write(csv_docs.getvalue())
|
| 46 |
csv_loader = CSVLoader(temp_filepath)
|
| 47 |
+
csv_docs = csv_loader.load()
|
| 48 |
+
return csv_docs
|
| 49 |
|
| 50 |
+
# json ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์์
๋๋ค.
|
| 51 |
+
def get_json_file(json_docs):
|
| 52 |
temp_dir = tempfile.TemporaryDirectory()
|
| 53 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
| 54 |
with open(temp_filepath, "wb") as f:
|
| 55 |
f.write(json_docs.getvalue())
|
| 56 |
+
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=True)
|
| 57 |
+
json_docs = json_loader.load()
|
| 58 |
+
return json_docs
|
| 59 |
+
|
| 60 |
|
| 61 |
|
| 62 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|