Update app.py
Browse files
app.py
CHANGED
@@ -43,14 +43,14 @@ def get_csv_file(docs):
|
|
43 |
return csv_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
44 |
|
45 |
def get_json_file(docs):
|
46 |
-
temp_dir = tempfile.TemporaryDirectory()
|
47 |
-
temp_filepath = os.path.join(temp_dir.name,
|
48 |
-
with open(temp_filepath, "wb") as f:
|
49 |
-
f.write(
|
50 |
-
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=False)
|
51 |
-
json_doc = json_loader.load()
|
52 |
-
|
53 |
-
|
54 |
|
55 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
56 |
def get_text_chunks(documents):
|
|
|
43 |
return csv_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
44 |
|
45 |
def get_json_file(docs):
|
46 |
+
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
47 |
+
temp_filepath = os.path.join(temp_dir.name, "temp_file.json") # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
48 |
+
with open(temp_filepath, "wb") as f:
|
49 |
+
f.write(docs.getvalue()) # JSON ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
50 |
+
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=False) # JSONLoader๋ฅผ ์ฌ์ฉํด JSON๋ฅผ ๋ก๋ํฉ๋๋ค.
|
51 |
+
json_doc = json_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
52 |
+
|
53 |
+
return json_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค
|
54 |
|
55 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
56 |
def get_text_chunks(documents):
|