tlsgy commited on
Commit
a3302ec
ยท
1 Parent(s): 060bc16
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -50,12 +50,14 @@ def get_csv_file(docs):
50
  return data
51
 
52
  def get_json_file(docs):
53
- # ์—…๋กœ๋“œ๋œ ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ๋ฌธ์ž์—ด๋กœ ์ฝ์–ด์˜ต๋‹ˆ๋‹ค.
54
- json_content = docs.read().decode('utf-8')
55
-
 
 
56
  # JSONLoader๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ž์—ด์„ JSON์œผ๋กœ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
57
  loader = JSONLoader(
58
- file_content=json_content,
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
  )