DDingcheol commited on
Commit
72eb9e9
Β·
1 Parent(s): 5475d7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -50,12 +50,14 @@ 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(file_path=temp_filepath, jq_schema='.messages[].content', text_content=False)
 
55
  json_doc = json_loader.load()
56
  return json_doc
57
 
58
 
 
59
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
60
  def get_text_chunks(documents):
61
  text_splitter = RecursiveCharacterTextSplitter(
 
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.read()) # 파일의 λ‚΄μš©μ„ μ“°κΈ° μœ„ν•΄ read()λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
54
+
55
+ json_loader = JSONLoader(file_path=temp_filepath)
56
  json_doc = json_loader.load()
57
  return json_doc
58
 
59
 
60
+
61
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
62
  def get_text_chunks(documents):
63
  text_splitter = RecursiveCharacterTextSplitter(