Spaces:
Runtime error
Runtime error
Update app.py
#3
by
hula0627
- opened
app.py
CHANGED
@@ -29,14 +29,31 @@ def get_pdf_text(pdf_docs):
|
|
29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
30 |
|
31 |
def get_text_file(docs):
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
def get_json_file(docs):
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
|
|
29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
30 |
|
31 |
def get_text_file(docs):
|
32 |
+
temp_dir = tempfile.TemporaryDirectory()
|
33 |
+
temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
|
34 |
+
with open(temp_filepath, "wb") as f:
|
35 |
+
f.write(txt_docs.getvalue())
|
36 |
+
txt_loader = TextLoader(temp_filepath)
|
37 |
+
txt_doc = txt_loader.load()
|
38 |
+
return txt_doc
|
39 |
+
|
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 |
+
with open(temp_filepath, "wb") as f:
|
44 |
+
f.write(csv_docs.getvalue())
|
45 |
+
csv_loader = CSVLoader(file_path=temp_filepath)
|
46 |
+
csv_doc = csv_loader.load()
|
47 |
+
return csv_doc
|
48 |
|
49 |
def get_json_file(docs):
|
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)
|
55 |
+
json_doc = json_loader.load()
|
56 |
+
return json_doc
|
57 |
|
58 |
|
59 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|