dakkoong commited on
Commit
0490b5b
โ€ข
1 Parent(s): 60398be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
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, "temp.json")
52
-
53
- # json_docs๋ฅผ bytes๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ํŒŒ์ผ์— ์“ฐ๊ธฐ
54
  with open(temp_filepath, "wb") as f:
55
- f.write(json_docs.getvalue().encode('utf-8')) # json_docs๋ฅผ bytes๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์“ฐ๊ธฐ
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):