B1ueccc commited on
Commit Β·
788a9d8
1
Parent(s): f5f492b
update app.py
Browse files
app.py
CHANGED
|
@@ -28,16 +28,33 @@ def get_pdf_text(pdf_docs):
|
|
| 28 |
# κ³Όμ
|
| 29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
| 30 |
|
| 31 |
-
def get_text_file(
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
| 43 |
def get_text_chunks(documents):
|
|
|
|
| 28 |
# κ³Όμ
|
| 29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
| 30 |
|
| 31 |
+
def get_text_file(txt_files):
|
| 32 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 33 |
+
temp_filepath = os.path.join(temp_dir.name, txt_files.name)
|
| 34 |
+
with open(temp_filepath, "wb") as f:
|
| 35 |
+
f.write(txt_files.getvalue())
|
| 36 |
+
text_loader = TextLoader(temp_filepath)
|
| 37 |
+
text_file = text_loader.load()
|
| 38 |
+
return text_file
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def get_csv_file(csv_files):
|
| 42 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 43 |
+
temp_filepath = os.path.join(temp_dir.name, csv_files.name)
|
| 44 |
+
with open(temp_filepath, "wb") as f:
|
| 45 |
+
f.write(csv_files.getvalue())
|
| 46 |
+
csv_loader = CSVLoader(temp_filepath)
|
| 47 |
+
csv_file = csv_loader.load()
|
| 48 |
+
return csv_file
|
| 49 |
+
|
| 50 |
+
def get_json_file(json_files):
|
| 51 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 52 |
+
temp_filepath = os.path.join(temp_dir.name, json_files.name)
|
| 53 |
+
with open(temp_filepath, "wb") as f:
|
| 54 |
+
f.write(json_files.getvalue())
|
| 55 |
+
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=False)
|
| 56 |
+
json_file = json_loader.load()
|
| 57 |
+
return json_file
|
| 58 |
|
| 59 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
| 60 |
def get_text_chunks(documents):
|