api-server/rag-worker/startup.sh

22 lines
636 B
Bash
Raw Normal View History

#!/bin/bash
# zhixi-worker startup checks — called by systemd ExecStartPre
set -e
cd /opt/zhixi/backend/rag-worker
# Install any new dependencies
/usr/bin/python3.11 -m pip install -q -r requirements.txt \
-i https://mirrors.tencentyun.com/pypi/simple
# Self-test: reranker
/usr/bin/python3.11 -c "
import asyncio
from reranker import rerank
async def t():
r = await rerank('测试', ['这是测试文本', '无关内容'], top_n=1)
if not r:
raise RuntimeError('reranker returned empty')
print(f'[self-test] reranker OK, score={r[0][\"score\"]:.4f}')
asyncio.run(t())
print('[self-test] all checks passed')
"