diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 23dfd75..b694ac5 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -84,6 +84,41 @@ jobs: $ENV_FILE \ zhixi-api:latest + - name: Deploy RAG Worker + run: | + WORKER_DIR="/opt/zhixi/backend/rag-worker" + mkdir -p "$WORKER_DIR" + + # Sync worker code from checkout (exclude .env to avoid overwriting secrets) + rsync -av --delete --exclude='.env' --exclude='__pycache__' \ + /tmp/api-server/rag-worker/ "$WORKER_DIR/" + + # Install any new Python dependencies + /usr/bin/python3.11 -m pip install -r "$WORKER_DIR/requirements.txt" \ + -i https://mirrors.tencentyun.com/pypi/simple 2>&1 | tail -3 + + # Reload systemd and restart worker + systemctl daemon-reload + systemctl restart zhixi-worker + sleep 3 + systemctl is-active zhixi-worker && echo "[deploy] zhixi-worker restarted OK" + + # Test reranker + cd "$WORKER_DIR" + /usr/bin/python3.11 -c " + import asyncio + from reranker import rerank + async def t(): + r = await rerank('什么是主动回忆', [ + '主动回忆是一种高效的学习策略,通过主动从记忆中提取信息来强化神经连接', + '苹果是一种常见的水果,富含维生素C', + '间隔重复和主动回忆结合使用效果更佳', + ], top_n=2) + for x in r: + print(f'[rerank-test] score={x[\"score\"]:.4f} text={x[\"text\"][:40]}') + asyncio.run(t()) + " && echo "[deploy] Reranker test OK" + - name: Health check run: | sleep 8