feat: 添加日志记录功能,输出至 app.log 文件
This commit is contained in:
@@ -13,7 +13,13 @@ import ssl
|
||||
import requests
|
||||
import warnings
|
||||
from langchain_chroma import Chroma
|
||||
|
||||
logging.basicConfig(
|
||||
filename='app.log', # 日志文件名
|
||||
filemode='a', # 追加模式('w' 会覆盖)
|
||||
level=logging.INFO, # 记录 INFO 及以上级别的日志
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
)
|
||||
# 禁用特定的Torch警告
|
||||
warnings.filterwarnings('ignore', message='.*Torch was not compiled with flash attention.*')
|
||||
os.environ["TOKENIZERS_PARALLELISM"] = "false" # 禁用tokenizer并行警告
|
||||
@@ -146,8 +152,8 @@ def split_text_for_vectorstore(chapter_text: str, max_length: int = 500, similar
|
||||
if not chapter_text.strip():
|
||||
return []
|
||||
|
||||
nltk.download('punkt', quiet=True)
|
||||
nltk.download('punkt_tab', quiet=True)
|
||||
# nltk.download('punkt', quiet=True)
|
||||
# nltk.download('punkt_tab', quiet=True)
|
||||
sentences = nltk.sent_tokenize(chapter_text)
|
||||
if not sentences:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user