minji1115
commited on
Commit
ยท
f573dc7
1
Parent(s):
49cc238
fin
Browse files
app.py
CHANGED
@@ -29,20 +29,32 @@ def get_pdf_text(pdf_docs):
|
|
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 |
|
41 |
def get_csv_file(csv_docs):
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
def get_json_file(json_docs):
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
|
|
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 |
|
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 |
def get_json_file(json_docs):
|
51 |
+
temp_dir = tempfile.TemporaryDirectory()
|
52 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
53 |
+
with open(temp_filepath, "wb") as f:
|
54 |
+
f.write(json_docs.getvalue())
|
55 |
+
json_loader = JSONLoader(temp_filepath, '.messages[].content')
|
56 |
+
json_docs = json_loader.load()
|
57 |
+
return json_docs
|
58 |
|
59 |
|
60 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|