Replace unsafe gitee nltk path with safe local 'nltk_data' references; update Dockerfile/Docker Compose/.env
This commit is contained in:
parent
3f98be1d00
commit
7f5774fa37
|
|
@ -105,7 +105,7 @@ AUTO_SYNC=true
|
|||
# ============================================
|
||||
# NLTK 配置
|
||||
# 推荐:如果你已在仓库内保存了 NLTK 数据(离线使用),可以设置为相对路径。例如:
|
||||
# ./https:/gitee.com/gislite/nltk_data/raw/gh-pages/
|
||||
# ./nltk_data/
|
||||
# 或者使用本地绝对路径: /path/to/nltk_data
|
||||
# ============================================
|
||||
NLTK_DATA=./https:/gitee.com/gislite/nltk_data/raw/gh-pages/
|
||||
NLTK_DATA=./nltk_data/
|
||||
|
|
|
|||
|
|
@ -134,5 +134,5 @@ docker-images-export/
|
|||
|
||||
# Allow checked-in NLTK data stored under the `https:/` path for offline use
|
||||
# These lines explicitly un-ignore that folder so files like .txt/.pickle are tracked.
|
||||
!https:/gitee.com/gislite/nltk_data/raw/gh-pages/
|
||||
!https:/gitee.com/gislite/nltk_data/raw/gh-pages/**
|
||||
!nltk_data/
|
||||
!nltk_data/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ ENV PYTHONUNBUFFERED=1 \
|
|||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
NLTK_DATA=https://gitee.com/gislite/nltk_data/raw/gh-pages/
|
||||
NLTK_DATA=/app/nltk_data/
|
||||
|
||||
# 配置国内 apt 镜像源(加速包下载)
|
||||
# 使用阿里云 Debian 镜像源(适用于 Debian/Ubuntu 系统)
|
||||
|
|
|
|||
|
|
@ -127,9 +127,8 @@ class Settings(BaseSettings):
|
|||
# use that; otherwise fall back to the official raw GitHub mirror.
|
||||
_PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||
_NLTK_CANDIDATES = [
|
||||
os.path.join(_PROJECT_ROOT, 'https:/gitee.com/gislite/nltk_data/raw/gh-pages/'),
|
||||
os.path.join(_PROJECT_ROOT, 'https:/gitee.com/gislite/nltk_data/raw/gh-pages'),
|
||||
os.path.join(_PROJECT_ROOT, 'nltk_data'),
|
||||
os.path.join(_PROJECT_ROOT, './nltk_data'),
|
||||
]
|
||||
_DEFAULT_NLTK = next((p for p in _NLTK_CANDIDATES if os.path.isdir(p)),
|
||||
"https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/")
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ services:
|
|||
- AUTO_SYNC=${AUTO_SYNC:-true}
|
||||
|
||||
# NLTK 配置
|
||||
- NLTK_DATA=${NLTK_DATA:-./https:/gitee.com/gislite/nltk_data/raw/gh-pages/}
|
||||
- NLTK_DATA=${NLTK_DATA:-./nltk_data/}
|
||||
# 注意:使用 host 网络模式时,depends_on 可能无法正常工作
|
||||
# 因为 host 网络模式的容器不在 Docker 的默认网络中
|
||||
# 如果需要依赖 ChromaDB,可以手动检查或使用启动脚本
|
||||
|
|
|
|||
2
main.py
2
main.py
|
|
@ -15,7 +15,7 @@ warnings.filterwarnings("ignore", message=".*pkg_resources is deprecated.*", cat
|
|||
if not os.environ.get("NLTK_DATA"):
|
||||
logger.warning(
|
||||
"NLTK_DATA 环境变量未设置,这可能导致 llama_index 导入较慢。"
|
||||
"建议设置本地路径,例如: export NLTK_DATA=./https:/gitee.com/gislite/nltk_data/raw/gh-pages/"
|
||||
"建议设置本地路径,例如: export NLTK_DATA=./nltk_data/"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue