Update app.py
Browse files
app.py
CHANGED
@@ -48,22 +48,16 @@ def get_csv_file(csv_docs):
|
|
48 |
|
49 |
def get_json_file(json_docs):
|
50 |
temp_dir = tempfile.TemporaryDirectory()
|
51 |
-
temp_filepath = os.path.join(temp_dir.name,
|
52 |
-
|
53 |
-
# json_docs๋ฅผ bytes๋ก ๋ณํํ์ฌ ํ์ผ์ ์ฐ๊ธฐ
|
54 |
with open(temp_filepath, "wb") as f:
|
55 |
-
f.write(json_docs.getvalue()
|
56 |
-
|
57 |
-
# JSONLoader๋ฅผ ์ฌ์ฉํ์ฌ ํ์ผ ๋ก๋
|
58 |
json_loader = JSONLoader(
|
59 |
file_path=temp_filepath,
|
60 |
jq_schema='.messages[].content',
|
61 |
text_content=False
|
62 |
)
|
63 |
-
|
64 |
-
json_doc = json_loader.load_json() # load_json ํจ์๋ฅผ ์ฌ์ฉํ๋๋ก ์์
|
65 |
return json_doc
|
66 |
-
|
67 |
|
68 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
69 |
def get_text_chunks(documents):
|
|
|
48 |
|
49 |
def get_json_file(json_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(
|
55 |
file_path=temp_filepath,
|
56 |
jq_schema='.messages[].content',
|
57 |
text_content=False
|
58 |
)
|
59 |
+
json_doc = json_loader.load()
|
|
|
60 |
return json_doc
|
|
|
61 |
|
62 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
63 |
def get_text_chunks(documents):
|