Spaces:
Runtime error
Runtime error
Commit ·
cb8d145
1
Parent(s): a6850e4
Update app.py
Browse files27 unmodified lines28293031323334353637383940414227 unmodified lines# 과제# 아래 텍스트 추출 함수를 작성def get_text_file(docs):passdef get_csv_file(docs):passdef get_json_file(docs):pass# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.27 unmodified lines282930313233343536373839404142434445464748495051525354555657585960616263646527 unmodified lines# 과제# 아래 텍스트 추출 함수를 작성def get_text_file(text_docs):temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.temp_filepath = os.path.join(temp_dir.name, text_docs.name) # 임시 파일 경로를 생성합니다.with open(temp_filepath, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.f.write(text_docs.getvalue())text_loader = TextLoader(temp_filepath)text_doc = text_loader.load()return text_docdef get_csv_file(csv_docs):temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.temp_filepath = os.path.join(temp_dir.name, csv_docs.name) # 임시 파일 경로를 생성합니다.with open(temp_filepath, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.f.write(csv_docs.getvalue())csv_loader = CSVLoader(temp_filepath)csv_doc = csv_loader.load()return csv_docdef get_json_file(json_docs):temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.temp_filepath = os.path.join(temp_dir.name, json_docs.name) # 임시 파일 경로를 생성합니다.with open(temp_filepath, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.f.write(json_docs.getvalue())json_loader = JSONLoader(temp_filepath,jq_schema='.scans[].relationships',text_content=False)json_doc = json_loader.load()return json_doc# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
app.py+29-6