fix: add HuggingFace mirror support for China network
- Add HF_ENDPOINT configuration option - Set HuggingFace mirror to https://hf-mirror.com - Fix 'cannot connect to huggingface.co' error - Update .env.example with HF_ENDPOINT setting Problem: - RAG engine uses sentence-transformers model - Model download requires connection to huggingface.co - China network cannot access huggingface.co - Error: 'We couldn't connect to https://huggingface.co' Solution: - Add HF_ENDPOINT environment variable support - Use hf-mirror.com as HuggingFace mirror - Set mirror before loading sentence-transformers - Document in .env.example Files: - backend/app/config.py: add HF_ENDPOINT config - backend/app/core/rag_engine.py: set HF_ENDPOINT before model load - backend/setup_hf_mirror.sh: setup script - backend/.env: configure mirror (not tracked)
This commit is contained in:
24
backend/setup_hf_mirror.sh
Normal file
24
backend/setup_hf_mirror.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# 设置 HuggingFace 镜像环境变量
|
||||
|
||||
echo "配置 HuggingFace 镜像..."
|
||||
|
||||
# 添加到 .env 文件
|
||||
if ! grep -q "HF_ENDPOINT" /data/erp-ass/backend/.env; then
|
||||
echo "" >> /data/erp-ass/backend/.env
|
||||
echo "# HuggingFace Mirror" >> /data/erp-ass/backend/.env
|
||||
echo "HF_ENDPOINT=https://hf-mirror.com" >> /data/erp-ass/backend/.env
|
||||
echo "✓ 已添加 HF_ENDPOINT 到 .env"
|
||||
else
|
||||
echo "✓ HF_ENDPOINT 已存在"
|
||||
fi
|
||||
|
||||
# 设置当前会话环境变量
|
||||
export HF_ENDPOINT=https://hf-mirror.com
|
||||
|
||||
echo ""
|
||||
echo "环境变量已设置:"
|
||||
echo " HF_ENDPOINT=https://hf-mirror.com"
|
||||
echo ""
|
||||
echo "请重启后端服务:"
|
||||
echo " ./stop.sh && ./start.sh"
|
||||
Reference in New Issue
Block a user