feat(rag): 接入 rag 知识库模块 + uapi 外部 API 网关
- app/pipeline_app.py: load_uapi() + init_rag_module()(uapi 必须先于 rag) - build.sh: 四处模块列表加 uapi/rag(clone/pip/xls2ui/wwwroot symlink) 新增 8b 步骤:json2ddl 建 rag_* 表 + 导入 uapi_seed.sql 配置种子 - wwwroot/index.ui: 侧边栏加「知识库」菜单项(open_tab 符合 UI 导航契约) - i18n zh/en/jp/ko: 补知识库相关四语言文案 rag 表统一 rag_ 前缀,与产线业务表隔离;数据独立于 ragserver
This commit is contained in:
parent
fb853ca350
commit
8e09c5389a
@ -44,6 +44,16 @@ def init():
|
||||
from smssend import load_smssend
|
||||
except ImportError:
|
||||
def load_smssend(): pass
|
||||
# uapi:外部 API 网关(rag 模块依赖它调 vdb/reranker/ner/graph)
|
||||
try:
|
||||
from uapi.init import load_uapi
|
||||
except ImportError:
|
||||
def load_uapi(): pass
|
||||
# rag:知识库(向量检索 + 图谱),表名统一 rag_ 前缀,与产线业务表不冲突
|
||||
try:
|
||||
from rag.init import init_rag_module
|
||||
except ImportError:
|
||||
def init_rag_module(): pass
|
||||
|
||||
set_globalvariable()
|
||||
ServerEnv().get_module_dbname = get_module_dbname
|
||||
@ -60,6 +70,8 @@ def init():
|
||||
load_tenant()
|
||||
load_ktv_adapter()
|
||||
load_smssend()
|
||||
load_uapi() # 必须在 rag 之前:rag 通过 uapi 调 vdb/reranker/ner/graph
|
||||
init_rag_module()
|
||||
|
||||
# Permission cache warms up on first request
|
||||
|
||||
|
||||
44
build.sh
44
build.sh
@ -53,7 +53,7 @@ for mod in pipeline_core pipeline_ops pipeline_dist; do
|
||||
done
|
||||
|
||||
# 5. Install business modules (clone external, local already in pkgs)
|
||||
for mod in pipeline-sdlc showcase evaluate pipeline-service pipeline-task tenant app_audit product_management discount pricing unipay smssend accounting; do
|
||||
for mod in pipeline-sdlc showcase evaluate pipeline-service pipeline-task tenant app_audit product_management discount pricing unipay smssend accounting uapi rag; do
|
||||
cd "$cdir/pkgs"
|
||||
if [ ! -d "$mod" ]; then
|
||||
git clone https://git.opencomputing.cn/yumoqing/$mod || echo "SKIP: $mod"
|
||||
@ -62,7 +62,7 @@ for mod in pipeline-sdlc showcase evaluate pipeline-service pipeline-task tenant
|
||||
done
|
||||
|
||||
# 6. pip install all modules from pkgs/(pipeline-service 是普通 install 非 editable,部署必 pull+pip install 都做)
|
||||
for mod in pipeline_core pipeline_ops pipeline_dist pipeline-sdlc showcase pipeline-service tenant app_audit product_management discount pricing unipay smssend accounting; do
|
||||
for mod in pipeline_core pipeline_ops pipeline_dist pipeline-sdlc showcase pipeline-service tenant app_audit product_management discount pricing unipay smssend accounting uapi rag; do
|
||||
if [ -d "pkgs/$mod" ]; then
|
||||
"$cdir/py3/bin/pip" install "pkgs/$mod/" 2>&1 | tail -1
|
||||
fi
|
||||
@ -89,7 +89,7 @@ if [ -d "pkgs/pipeline_core/skills_library" ]; then
|
||||
fi
|
||||
|
||||
# 7. Regenerate CRUD from json for all pipeline modules
|
||||
for mod in appbase pipeline_core pipeline_ops pipeline_dist pipeline-sdlc rbac dapi accounting; do
|
||||
for mod in appbase pipeline_core pipeline_ops pipeline_dist pipeline-sdlc rbac dapi accounting uapi rag; do
|
||||
json_dir="pkgs/$mod/json"
|
||||
models_dir="pkgs/$mod/models"
|
||||
wwwroot_dir="pkgs/$mod/wwwroot"
|
||||
@ -102,7 +102,7 @@ done
|
||||
|
||||
|
||||
# 8. Link module wwwroot directories (symlinks from pkgs/)
|
||||
for mod in pipeline-sdlc showcase tenant pipeline_core pipeline_ops pipeline_dist appbase app_audit product_management discount pricing unipay rbac dapi accounting; do
|
||||
for mod in pipeline-sdlc showcase tenant pipeline_core pipeline_ops pipeline_dist appbase app_audit product_management discount pricing unipay rbac dapi accounting uapi rag; do
|
||||
src="pkgs/$mod/wwwroot"
|
||||
dst="wwwroot/$mod"
|
||||
if [ -d "$src" ]; then
|
||||
@ -114,6 +114,42 @@ done
|
||||
# pipeline_task has no separate module
|
||||
mkdir -p wwwroot/pipeline_task
|
||||
|
||||
# 8b. rag 模块:建 rag_* 表 + 导入 uapi 外部服务配置种子
|
||||
# rag 表统一 rag_ 前缀,与产线业务表隔离;数据独立于 ragserver(同代码不同宿主,各自的数据)
|
||||
if [ -d "pkgs/rag/models" ] && ls pkgs/rag/models/*.json >/dev/null 2>&1; then
|
||||
cd "$cdir/pkgs/rag/models"
|
||||
"$cdir/py3/bin/json2ddl" mysql . > /tmp/pipeline_rag_ddl.sql || {
|
||||
echo "ERROR: rag json2ddl failed" >&2; cd "$cdir"; exit 1; }
|
||||
if [ ! -s /tmp/pipeline_rag_ddl.sql ]; then
|
||||
echo "ERROR: rag DDL empty — check models/*.json (need summary+fields)" >&2
|
||||
cd "$cdir"; exit 1
|
||||
fi
|
||||
cd "$cdir"
|
||||
"$cdir/py3/bin/python" - <<'PYEOF'
|
||||
import sys, os, subprocess
|
||||
sys.path.insert(0, os.getcwd())
|
||||
from appPublic.jsonConfig import getConfig
|
||||
from appPublic.aes import aes_decode_b64
|
||||
cfg = getConfig('.', {'workdir': '.'})
|
||||
kw = cfg.databases['pipeline'].kwargs
|
||||
pwd = aes_decode_b64(cfg.password_key, kw.password)
|
||||
for sqlfile in ['/tmp/pipeline_rag_ddl.sql', 'pkgs/rag/init/uapi_seed.sql']:
|
||||
if not os.path.exists(sqlfile):
|
||||
print(' SKIP (missing): %s' % sqlfile)
|
||||
continue
|
||||
with open(sqlfile, 'rb') as f:
|
||||
r = subprocess.run(['mysql', '-h', str(kw.host), '-P', str(kw.port),
|
||||
'-u', str(kw.user), '-p%s' % pwd, str(kw.db)],
|
||||
stdin=f, capture_output=True)
|
||||
tag = os.path.basename(sqlfile)
|
||||
if r.returncode == 0:
|
||||
print(' rag: %s applied' % tag)
|
||||
else:
|
||||
err = r.stderr.decode('utf-8', 'replace').strip().split(chr(10))[0]
|
||||
print(' WARN rag %s: %s' % (tag, err[:160]))
|
||||
PYEOF
|
||||
fi
|
||||
|
||||
# 9. Sync password_key from Sage (not databases — those are app-specific)
|
||||
if [ -f /d/apitest/sage/conf/config.json ]; then
|
||||
python3 -c "
|
||||
|
||||
@ -17,3 +17,7 @@ Submit: Submit
|
||||
展示平台: Display Platform
|
||||
管理: Management
|
||||
运营管理: Operations Management
|
||||
知识库: Knowledge Base
|
||||
向量引擎: Vector Engine
|
||||
多媒体(图文音视): Multimedia (image/audio/video)
|
||||
文本(文档检索): Text (document retrieval)
|
||||
|
||||
@ -17,3 +17,7 @@ Submit: 送信
|
||||
展示平台: 表示プラットフォーム
|
||||
管理: 管理
|
||||
运营管理: 運用管理
|
||||
知识库: ナレッジベース
|
||||
向量引擎: ベクトルエンジン
|
||||
多媒体(图文音视): マルチメディア(画像・音声・動画)
|
||||
文本(文档检索): テキスト(文書検索)
|
||||
|
||||
@ -17,3 +17,7 @@ Submit: 제출
|
||||
展示平台: 표시 플랫폼
|
||||
管理: 관리
|
||||
运营管理: 운영 관리
|
||||
知识库: 지식 베이스
|
||||
向量引擎: 벡터 엔진
|
||||
多媒体(图文音视): 멀티미디어(이미지/음성/영상)
|
||||
文本(文档检索): 텍스트(문서 검색)
|
||||
|
||||
@ -17,3 +17,7 @@ Submit: Submit
|
||||
展示平台: 展示平台
|
||||
管理: 管理
|
||||
运营管理: 运营管理
|
||||
知识库: 知识库
|
||||
向量引擎: 向量引擎
|
||||
多媒体(图文音视): 多媒体(图文音视)
|
||||
文本(文档检索): 文本(文档检索)
|
||||
|
||||
@ -165,6 +165,12 @@
|
||||
"icon": "{{entire_url('/imgs/mic.svg')}}",
|
||||
"script": "this.open_tab({name:'pipeline_ktv',label:'KTV产线',url:'/pipeline_task/task_submit.ui',removable:true})"
|
||||
},
|
||||
{
|
||||
"name": "rag_kb",
|
||||
"label": "知识库",
|
||||
"icon": "{{entire_url('/imgs/database.svg')}}",
|
||||
"script": "this.open_tab({name:'rag_kb',label:'知识库',url:'/rag/knowledge_bases_list/index.ui',removable:true})"
|
||||
},
|
||||
{
|
||||
"name": "showcase",
|
||||
"label": "展示平台",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user