Update app.py
Browse files
app.py
CHANGED
|
@@ -25,33 +25,22 @@ def get_pdf_text(pdf_docs):
|
|
| 25 |
# ๊ณผ์
|
| 26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 27 |
|
| 28 |
-
def get_text_file(
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
return csv_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 45 |
-
|
| 46 |
-
def get_json_file(json_docs):
|
| 47 |
-
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
| 48 |
-
temp_filepath = os.path.join(temp_dir.name, "temp_file.json") # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
| 49 |
-
with open(temp_filepath, "wb") as f:
|
| 50 |
-
f.write(json_docs.getvalue()) # JSON ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
| 51 |
-
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=False) # JSONLoader๋ฅผ ์ฌ์ฉํด JSON๋ฅผ ๋ก๋ํฉ๋๋ค.
|
| 52 |
-
json_doc = json_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
| 53 |
-
return json_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 54 |
-
|
| 55 |
|
| 56 |
|
| 57 |
|
|
|
|
| 25 |
# ๊ณผ์
|
| 26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 27 |
|
| 28 |
+
def get_text_file(docs):
|
| 29 |
+
# Assuming the document is a text file
|
| 30 |
+
text = docs.getvalue().decode('utf-8')
|
| 31 |
+
return [text]
|
| 32 |
+
|
| 33 |
+
def get_csv_file(docs):
|
| 34 |
+
# Assuming the document is a CSV file
|
| 35 |
+
csv_loader = CSVLoader(docs)
|
| 36 |
+
csv_doc = csv_loader.load()
|
| 37 |
+
return csv_doc
|
| 38 |
+
|
| 39 |
+
def get_json_file(docs):
|
| 40 |
+
# Assuming the document is a JSON file
|
| 41 |
+
json_loader = JSONLoader(docs)
|
| 42 |
+
json_doc = json_loader.load()
|
| 43 |
+
return json_doc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
|