fix: 修复本地llm服务不可用问题 + 统一模型缓存目录位置
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled

- 修复 config.py 添加 LOCAL_MODEL_NAME 配置项
- 修复 chat_services.py 本地模型检测时API路径重复问题(/v1/models -> /models)
- 更新 .gitignore,移除模型目录跟踪
- 统一模型缓存到 docker/models/fastembed_cache,避免重复
- 更新 Dockerfile,正确复制预下载的BM25模型缓存
This commit is contained in:
2026-05-04 03:26:19 +08:00
parent 8af82f8f7f
commit 44d89acdb5
44 changed files with 11 additions and 3928 deletions

View File

@@ -72,7 +72,7 @@ COPY docker/models/ /tmp/models/
# 安装本地模型 wheel如果有 .whl 文件)
RUN find /tmp/models -name "*.whl" -type f 2>/dev/null | head -1 | xargs -r pip install --no-cache-dir && \
rm -rf /tmp/models
rm -rf /tmp/models/*.whl # 只删除 wheel保留 fastembed_cache
# 设置 pip 国内镜像源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
@@ -81,18 +81,11 @@ RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
COPY backend/requirements.txt .
RUN pip install --no-cache-dir --default-timeout=300 -r requirements.txt
# =============================================================================
# 下载稀疏模型(关键步骤:在构建阶段下载到固定目录)
# =============================================================================
RUN mkdir -p /app/models/sparse
COPY download_sparse_model.py .
RUN python download_sparse_model.py --cache-dir /app/models/sparse --model-name Qdrant/bm25 && \
rm -f download_sparse_model.py
# =============================================================================
# 复制预下载的BM25模型缓存FastEmbed
# =============================================================================
COPY models/fastembed_cache /app/fastembed_cache
# 注意:模型在 docker/models/fastembed_cache
COPY docker/models/fastembed_cache /app/fastembed_cache
# =============================================================================
# 复制项目代码