Spaces:
Runtime error
Runtime error
se0kcess
commited on
Commit
โข
8e40ce2
1
Parent(s):
950d69e
"update"
Browse files
app.py
CHANGED
@@ -25,28 +25,42 @@ def get_pdf_text(pdf_docs):
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
def get_text_file(txt_docs):
|
28 |
-
temp_dir = tempfile.TemporaryDirectory()
|
29 |
-
temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
|
30 |
|
31 |
with open(temp_filepath, "w", encoding="utf-8") as f:
|
32 |
-
f.write(txt_docs.getvalue())
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
return
|
38 |
|
39 |
# CSV ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
40 |
-
def get_csv_file(
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# JSON ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
46 |
-
def get_json_file(
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
52 |
def get_text_chunks(documents):
|
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
def get_text_file(txt_docs):
|
28 |
+
temp_dir = tempfile.TemporaryDirectory()
|
29 |
+
temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
|
30 |
|
31 |
with open(temp_filepath, "w", encoding="utf-8") as f:
|
32 |
+
f.write(txt_docs.getvalue())
|
33 |
+
|
34 |
+
text_loader = TextLoader(temp_filepath)
|
35 |
+
text_data = text_loader.load()
|
36 |
+
|
37 |
+
return text_data
|
38 |
|
39 |
# CSV ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
40 |
+
def get_csv_file(csv_docs):
|
41 |
+
temp_dir = tempfile.TemporaryDirectory()
|
42 |
+
temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
|
43 |
+
|
44 |
+
with open(temp_filepath, "w", encoding="utf-8") as f:
|
45 |
+
f.write(csv_docs.getvalue())
|
46 |
+
|
47 |
+
csv_loader = CSVLoader(temp_filepath)
|
48 |
+
csv_data = csv_loader.load()
|
49 |
+
|
50 |
+
return csv_data
|
51 |
|
52 |
# JSON ํ์ผ๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
53 |
+
def get_json_file(json_docs):
|
54 |
+
temp_dir = tempfile.TemporaryDirectory()
|
55 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
56 |
+
|
57 |
+
with open(temp_filepath, "w", encoding="utf-8") as f:
|
58 |
+
f.write(json_docs.getvalue())
|
59 |
+
|
60 |
+
json_loader = JSONLoader(temp_filepath)
|
61 |
+
json_data = json_loader.load()
|
62 |
+
|
63 |
+
return json_data
|
64 |
|
65 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
66 |
def get_text_chunks(documents):
|