Update app.py
Browse files
app.py
CHANGED
@@ -28,26 +28,34 @@ def get_pdf_text(pdf_docs):
|
|
28 |
# κ³Όμ
|
29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
30 |
|
31 |
-
def get_text_file(
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
text_loader = TextLoader(temp_file.name)
|
36 |
text_doc = text_loader.load()
|
37 |
|
38 |
return text_doc
|
39 |
|
40 |
-
def get_csv_file(
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
-
return
|
48 |
|
49 |
-
def get_json_file(
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
|
|
28 |
# κ³Όμ
|
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_file.name)
|
37 |
text_doc = text_loader.load()
|
38 |
|
39 |
return text_doc
|
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_file.name)
|
47 |
+
csv_doc = csv_loader.load()
|
48 |
|
49 |
+
return csv_doc
|
50 |
|
51 |
+
def get_json_file(json_docs):
|
52 |
+
temp_dir = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
53 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
54 |
+
with open(temp_filepath, "wb") as f: # μμ νμΌμ λ°μ΄λ리 μ°κΈ° λͺ¨λλ‘ μ½λλ€.
|
55 |
+
f.write(json_docs.getvalue())
|
56 |
+
json_loader = JSONLoader(temp_file.name,jq_schema='.messages[].content',text_content=False)
|
57 |
+
json_doc=json_loader.load
|
58 |
+
return json_doc
|
59 |
|
60 |
|
61 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|