Update app.py
Browse files
app.py
CHANGED
@@ -49,15 +49,20 @@ def get_csv_file(csv_docs):
|
|
49 |
|
50 |
def get_json_file(json_docs):
|
51 |
temp_dir = tempfile.TemporaryDirectory()
|
52 |
-
temp_filepath = os.path.join(temp_dir.name,
|
|
|
|
|
53 |
with open(temp_filepath, "wb") as f:
|
54 |
-
f.write(json_docs.getvalue())
|
|
|
|
|
55 |
json_loader = JSONLoader(
|
56 |
file_path=temp_filepath,
|
57 |
jq_schema='.messages[].content',
|
58 |
text_content=False
|
59 |
)
|
60 |
-
|
|
|
61 |
return json_doc
|
62 |
|
63 |
|
|
|
49 |
|
50 |
def get_json_file(json_docs):
|
51 |
temp_dir = tempfile.TemporaryDirectory()
|
52 |
+
temp_filepath = os.path.join(temp_dir.name, "temp.json")
|
53 |
+
|
54 |
+
# json_docs를 bytes로 변환하여 파일에 쓰기
|
55 |
with open(temp_filepath, "wb") as f:
|
56 |
+
f.write(json_docs.getvalue().encode('utf-8')) # json_docs를 bytes로 변환하여 쓰기
|
57 |
+
|
58 |
+
# JSONLoader를 사용하여 파일 로드
|
59 |
json_loader = JSONLoader(
|
60 |
file_path=temp_filepath,
|
61 |
jq_schema='.messages[].content',
|
62 |
text_content=False
|
63 |
)
|
64 |
+
|
65 |
+
json_doc = json_loader.load_json() # load_json 함수를 사용하도록 수정
|
66 |
return json_doc
|
67 |
|
68 |
|