Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,14 +38,18 @@ def get_csv_file(csv_datas):
|
|
38 |
temp_filepath = os.path.join(temp_dir.name, csv_datas.name) # 임시 CSV 파일 경로를 생성합니다.
|
39 |
with open(temp_filepath, "w", newline="", encoding="utf-8") as csvfile: # CSV 파일을 쓰기 모드로 엽니다.
|
40 |
csvfile.write(csv_datas.getvalue()) # CSV 데이터를 파일에 씁니다.
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
def get_json_file(
|
44 |
temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
|
45 |
-
temp_filepath = os.path.join(temp_dir.name,
|
46 |
with open(temp_filepath, "w", encoding="utf-8") as jsonfile: # JSON 파일을 쓰기 모드로 엽니다.
|
47 |
-
jsonfile.write(
|
48 |
-
|
|
|
|
|
49 |
|
50 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
51 |
def get_text_chunks(documents):
|
|
|
38 |
temp_filepath = os.path.join(temp_dir.name, csv_datas.name) # 임시 CSV 파일 경로를 생성합니다.
|
39 |
with open(temp_filepath, "w", newline="", encoding="utf-8") as csvfile: # CSV 파일을 쓰기 모드로 엽니다.
|
40 |
csvfile.write(csv_datas.getvalue()) # CSV 데이터를 파일에 씁니다.
|
41 |
+
csv_loader = CSVLoader(temp_filepath)
|
42 |
+
csv_data = csv_loader.load()
|
43 |
+
return csv_data
|
44 |
|
45 |
+
def get_json_file(json_datas):
|
46 |
temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
|
47 |
+
temp_filepath = os.path.join(temp_dir.name, json_datas.name) # 임시 JSON 파일 경로를 생성합니다.
|
48 |
with open(temp_filepath, "w", encoding="utf-8") as jsonfile: # JSON 파일을 쓰기 모드로 엽니다.
|
49 |
+
jsonfile.write(json_datas.getvalue()) # JSON 데이터를 파일에 씁니다.
|
50 |
+
json_loader = JSONLoader(temp_filepath)
|
51 |
+
json_data = json_loader.load()
|
52 |
+
return json_data
|
53 |
|
54 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
55 |
def get_text_chunks(documents):
|