tlsgy commited on
Commit ยท
a3302ec
1
Parent(s): 060bc16
dd
Browse files
app.py
CHANGED
|
@@ -50,12 +50,14 @@ def get_csv_file(docs):
|
|
| 50 |
return data
|
| 51 |
|
| 52 |
def get_json_file(docs):
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
# JSONLoader๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌธ์์ด์ JSON์ผ๋ก ๋ก๋ํฉ๋๋ค.
|
| 57 |
loader = JSONLoader(
|
| 58 |
-
|
| 59 |
jq_schema='.messages[].content',
|
| 60 |
text_content=False
|
| 61 |
)
|
|
|
|
| 50 |
return data
|
| 51 |
|
| 52 |
def get_json_file(docs):
|
| 53 |
+
json_data = json.loads(docs)
|
| 54 |
+
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
| 55 |
+
temp_filepath = os.path.join(temp_dir.name, docs.name) # JSON ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
| 56 |
+
with open(temp_filepath, "w") as json_file: # JSON ํ์ผ์ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
| 57 |
+
json.dump(json_data, json_file) # ๋ฐ์ดํฐ๋ฅผ JSON ํ์ผ์ ์์ฑํฉ๋๋ค.
|
| 58 |
# JSONLoader๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌธ์์ด์ JSON์ผ๋ก ๋ก๋ํฉ๋๋ค.
|
| 59 |
loader = JSONLoader(
|
| 60 |
+
file_path=temp_filepath,
|
| 61 |
jq_schema='.messages[].content',
|
| 62 |
text_content=False
|
| 63 |
)
|