feat: 添加日志记录功能,输出至 app.log 文件

This commit is contained in:
acomic
2025-08-24 10:34:49 +08:00
parent 82ffceb9b1
commit d0029de080
8 changed files with 56 additions and 10 deletions
+9 -3
View File
@@ -16,11 +16,17 @@ from langchain.docstore.document import Document
# 禁用特定的Torch警告
warnings.filterwarnings('ignore', message='.*Torch was not compiled with flash attention.*')
os.environ["TOKENIZERS_PARALLELISM"] = "false"
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'
)
def advanced_split_content(content: str, similarity_threshold: float = 0.7, max_length: int = 500) -> list:
"""使用基本分段策略"""
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(content)
if not sentences:
return []