ragserver/build.sh
yumoqing 254bf8e9b2 feat: initial ragserver - web app skeleton with data models, CRUD, and build scripts
- ahserver web app on port 9190
- DB: rag (test/test123, utf8mb4)
- 7 data models: knowledge_bases, documents, document_chunks, entities, entity_relations, subscriptions, engine_configs, usage_logs
- 4 CRUD definitions: knowledge_bases, documents, subscriptions, engine_configs
- build.sh clones all foundation modules + rag-pipeline + services
- independent venv, bricks frontend, RBAC support
2026-07-21 17:00:53 +08:00

87 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
set -e
cdir=$(cd "$(dirname "$0")"; pwd)
# Environment
export SAGE_RBAC_DB=rag
# Virtualenv
if [ ! -d py3 ]; then
python3 -m venv py3
fi
source py3/bin/activate
# Install build tools
pip install -q xls2ddl
# pkgs directory
mkdir -p pkgs logs files
# Clone and install foundation modules
for repo in apppublic sqlor ahserver rbac appbase bricks-for-python; do
[ -d pkgs/$repo ] || git clone git@git.opencomputing.cn:yumoqing/$repo.git pkgs/$repo
pip install -q -e pkgs/$repo
done
# Clone and install rag-pipeline (core engine)
[ -d pkgs/rag-pipeline ] || git clone git@git.opencomputing.cn:yumoqing/rag-pipeline.git pkgs/rag-pipeline
pip install -q -e pkgs/rag-pipeline
# Clone service modules (for reference, not imported)
for svc in clip_embedding vdb bge-reranker face-service graph-service ner-service speaker-id; do
[ -d pkgs/$svc ] || git clone git@git.opencomputing.cn:yumoqing/$svc.git pkgs/$svc
done
# Build bricks frontend
if [ ! -d pkgs/bricks ]; then
git clone git@git.opencomputing.cn:yumoqing/bricks.git pkgs/bricks
fi
mkdir -p pkgs/bricks/dist/i18n
cd pkgs/bricks
bash build.sh
cd $cdir
# Symlink bricks
ln -sf pkgs/bricks/dist wwwroot/bricks 2>/dev/null || true
# Install appbase and rbac
pip install -q -e pkgs/appbase
pip install -q -e pkgs/rbac
# Generate DDL from models
if ls models/*.json >/dev/null 2>&1; then
cd models
json2ddl mysql . > mysql.ddl.sql
mysql -h db -utest -ptest123 rag < mysql.ddl.sql 2>/dev/null || echo "DDL already applied or mysql not available"
cd $cdir
fi
# Generate CRUD from json/
if ls json/*.json >/dev/null 2>&1; then
xls2ui -m models -o wwwroot ragserver json/*.json 2>/dev/null || true
fi
# Symlink module wwwroots
for m in rag-pipeline; do
[ -d pkgs/$m/wwwroot ] && ln -sf ../pkgs/$m/wwwroot wwwroot/$m 2>/dev/null || true
done
# Fix created_by in CRUD dspy files
if [ -d wwwroot/knowledge_bases_list ]; then
find wwwroot -name '*.dspy' -exec sed -i "s/ns\['created_by'\] = ''/ns['created_by'] = userorgid/" {} \; 2>/dev/null || true
fi
# Sync password_key from Sage if available
if [ -f /d/apitest/sage/conf/config.json ]; then
sage_key=$(python3 -c "import json; print(json.load(open('/d/apitest/sage/conf/config.json'))['password_key'])")
python3 -c "
import json
c = json.load(open('$cdir/conf/config.json'))
c['password_key'] = '$sage_key'
json.dump(c, open('$cdir/conf/config.json', 'w'), indent=4)
"
echo "password_key synced from Sage"
fi
echo "=== RAG Server build complete ==="