Karin0616 commited on
Commit
3e98e85
Β·
1 Parent(s): 88106a3
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -36,8 +36,16 @@ def get_csv_file(docs):
36
  pass
37
 
38
  def get_json_file(docs):
39
- pass
40
-
 
 
 
 
 
 
 
 
41
 
42
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
43
  def get_text_chunks(documents):
 
36
  pass
37
 
38
  def get_json_file(docs):
39
+ temp_dir = tempfile.TemporaryDirectory() # μž„μ‹œ 디렉토리λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
40
+ temp_filepath = os.path.join(temp_dir.name, docs.name) # μž„μ‹œ 파일 경둜λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
41
+ with open(temp_filepath, "wb") as f: # μž„μ‹œ νŒŒμΌμ„ λ°”μ΄λ„ˆλ¦¬ μ“°κΈ° λͺ¨λ“œλ‘œ μ—½λ‹ˆλ‹€.
42
+ f.write(docs.getvalue())
43
+ json_loader = JSONLoader(
44
+ file_path=temp_filepath,
45
+ jq_schema='.messages[].content',
46
+ text_content=False)
47
+ json_doc = json_loader.load()
48
+ return json_doc
49
 
50
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
51
  def get_text_chunks(documents):