Daoneeee commited on
Commit
0427804
·
1 Parent(s): fcafbc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -47,9 +47,14 @@ def get_csv_file(csv_docs):
47
  csv_doc = csv_loader.load() # 텍스트를 추출합니다.
48
  return csv_doc # 추출한 텍스트를 반환합니다.
49
 
50
- def get_json_file(docs):
51
- json_loader = JSONLoader(docs) # JSON 파일을 처리할 JSONLoader 사용
52
- return json_loader.load()
 
 
 
 
 
53
 
54
 
55
  # 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
 
47
  csv_doc = csv_loader.load() # 텍스트를 추출합니다.
48
  return csv_doc # 추출한 텍스트를 반환합니다.
49
 
50
+ def get_json_file(json_docs):
51
+ temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
52
+ temp_filepath = os.path.join(temp_dir.name, json_docs.name) # 임시 파일 경로를 생성합니다.
53
+ with open(temp_filepath, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.
54
+ f.write(json_docs.getvalue()) # PDF 문서의 내용을 임시 파일에 씁니다.
55
+ json_loader = JSONLoader(temp_filepath) # PyPDFLoader를 사용해 PDF를 로드합니다.
56
+ json_doc = json_loader.load() # 텍스트를 추출합니다.
57
+ return json_doc # 추출한 텍스트를 반환합니다.
58
 
59
 
60
  # 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.