5Grains commited on
Commit
5e67b52
Β·
1 Parent(s): 5edde92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -30,8 +30,16 @@ def get_text_file(docs):
30
  def get_csv_file(docs):
31
  pass
32
 
33
- def get_json_file(docs):
34
- pass
 
 
 
 
 
 
 
 
35
 
36
 
37
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
30
  def get_csv_file(docs):
31
  pass
32
 
33
+ def get_json_file(json_docs):
34
+ temp_dir = tempfile.TemporaryDirectory() # μž„μ‹œ 디렉토리λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
35
+ temp_filepath = os.path.join(temp_dir.name, json_docs.name) # μž„μ‹œ 파일 경둜λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
36
+ with open(temp_filepath, "wb") as f:
37
+ f.write(json_docs.getvalue())
38
+ file_path=temp_filepath,
39
+ jq_schema='.messages[].content',
40
+ text_content=False)
41
+ json_doc = json_loader.load()
42
+ return json_doc
43
 
44
 
45
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.