SeoJunn commited on
Commit
2bb96b1
Β·
1 Parent(s): 4c79716

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -51,16 +51,12 @@ def get_csv_file(csv_docs):
51
  return csv_doc # μΆ”μΆœν•œ ν…μŠ€νŠΈλ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
52
 
53
  def get_json_file(json_docs):
54
- temp_dir = tempfile.TemporaryDirectory() # Create a temporary directory.
55
- temp_filepath = os.path.join(temp_dir.name, json_docs.name) # Create a temporary file path.
56
-
57
- with open(temp_filepath, "wb") as f:
58
- f.write(json_docs.read()) # Write the content of the uploaded JSON file to the temporary file.
59
-
60
- loader = JSONLoader(file_path=temp_filepath, jq_schema='.messages[].content', text_content=False)
61
- data = loader.load()
62
-
63
- pprint(data) # Use pprint directly on the loaded data.
64
  return data
65
 
66
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
51
  return csv_doc # μΆ”μΆœν•œ ν…μŠ€νŠΈλ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
52
 
53
  def get_json_file(json_docs):
54
+ temp_dir = tempfile.TemporaryDirectory() # μž„μ‹œ 디렉토리λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
55
+ temp_filepath = os.path.join(temp_dir.name, json_docs.name) # μž„μ‹œ 파일 경둜λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
56
+ with open(temp_filepath, "wb") as f: # μž„μ‹œ νŒŒμΌμ„ λ°”μ΄λ„ˆλ¦¬ μ“°κΈ° λͺ¨λ“œλ‘œ μ—½λ‹ˆλ‹€.
57
+ f.write(json_docs.getvalue()) # PDF λ¬Έμ„œμ˜ λ‚΄μš©μ„ μž„μ‹œ νŒŒμΌμ— μ”λ‹ˆλ‹€.
58
+ json_loader = JSONLoader(file_path=temp_filepath, jq_schema='.messages[].content', text_content=False)
59
+ data = json_loader.load()
 
 
 
 
60
  return data
61
 
62
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.