file dynamic load

这个提交包含在:
binary-husky
2025-07-13 02:51:14 +08:00
父节点 a49085088c
当前提交 55607cbe8b
共有 6 个文件被更改,包括 583 次插入15 次删除

查看文件

@@ -230,6 +230,41 @@ def warm_up_modules():
enc.encode("模块预热", disallowed_special=())
enc = model_info["gpt-4"]['tokenizer']
enc.encode("模块预热", disallowed_special=())
try_warm_up_vectordb()
# def try_warm_up_vectordb():
# try:
# import os
# import nltk
# target = os.path.expanduser('~/nltk_data')
# logger.info(f'模块预热: nltk punkt (从Github下载部分文件到 {target})')
# nltk.data.path.append(target)
# nltk.download('punkt', download_dir=target)
# logger.info('模块预热完成: nltk punkt')
# except:
# logger.exception('模块预热: nltk punkt 失败,可能需要手动安装 nltk punkt')
# logger.error('模块预热: nltk punkt 失败,可能需要手动安装 nltk punkt')
def try_warm_up_vectordb():
import os
import nltk
target = os.path.expanduser('~/nltk_data')
nltk.data.path.append(target)
try:
# 尝试加载 punkt
nltk.data.find('tokenizers/punkt')
logger.info('nltk模块预热完成读取本地缓存')
except:
# 如果找不到,则尝试下载
try:
logger.info(f'模块预热: nltk punkt (从 Github 下载部分文件到 {target})')
nltk.download('punkt', download_dir=target)
logger.info('nltk模块预热完成')
except Exception:
logger.exception('模块预热: nltk punkt 失败,可能需要手动安装 nltk punkt')
def warm_up_vectordb():
"""