Tuchuanhuhuhu commited on
Commit
08b7713
·
1 Parent(s): 12eb16f

bugfix: 如果文件解析失败,不影响后续文件

Browse files
Files changed (1) hide show
  1. modules/index_func.py +4 -2
modules/index_func.py CHANGED
@@ -23,6 +23,7 @@ def get_documents(file_src):
23
  filename = os.path.basename(filepath)
24
  file_type = os.path.splitext(filename)[1]
25
  logging.info(f"loading file: {filename}")
 
26
  try:
27
  if file_type == ".pdf":
28
  logging.debug("Loading PDF...")
@@ -72,8 +73,9 @@ def get_documents(file_src):
72
  logging.error(f"Error loading file: {filename}")
73
  traceback.print_exc()
74
 
75
- texts = text_splitter.split_documents(texts)
76
- documents.extend(texts)
 
77
  logging.debug("Documents loaded.")
78
  return documents
79
 
 
23
  filename = os.path.basename(filepath)
24
  file_type = os.path.splitext(filename)[1]
25
  logging.info(f"loading file: {filename}")
26
+ texts = None
27
  try:
28
  if file_type == ".pdf":
29
  logging.debug("Loading PDF...")
 
73
  logging.error(f"Error loading file: {filename}")
74
  traceback.print_exc()
75
 
76
+ if texts is not None:
77
+ texts = text_splitter.split_documents(texts)
78
+ documents.extend(texts)
79
  logging.debug("Documents loaded.")
80
  return documents
81