please
Browse files
app.py
CHANGED
@@ -36,7 +36,6 @@ def get_text_file(text_docs):
|
|
36 |
f.write(text_docs.getvalue())
|
37 |
text_loader = TextLoader(temp_filepath)
|
38 |
text_content = text_loader.load()
|
39 |
-
temp_dir.cleanup()
|
40 |
return text_content
|
41 |
|
42 |
|
@@ -51,14 +50,13 @@ def get_csv_file(csv_docs):
|
|
51 |
|
52 |
|
53 |
def get_json_file(json_docs):
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
return json_content
|
62 |
|
63 |
|
64 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
|
|
36 |
f.write(text_docs.getvalue())
|
37 |
text_loader = TextLoader(temp_filepath)
|
38 |
text_content = text_loader.load()
|
|
|
39 |
return text_content
|
40 |
|
41 |
|
|
|
50 |
|
51 |
|
52 |
def get_json_file(json_docs):
|
53 |
+
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
54 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
55 |
+
with open(temp_filepath, "wb") as f: # ์์ ํ์ผ์ ๋ฐ์ด๋๋ฆฌ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
56 |
+
f.write(json_docs.getvalue()) # PDF ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
57 |
+
json_loader = JSONLoader(temp_filepath) # PyPDFLoader๋ฅผ ์ฌ์ฉํด PDF๋ฅผ ๋ก๋ํฉ๋๋ค.
|
58 |
+
json_doc = json_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
59 |
+
return json_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
|
|
60 |
|
61 |
|
62 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|