From 252f119f35a0be07651540def1f242a74066185f Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 1 Sep 2026 17:28:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(llm-govern):=20=E9=9B=86=E6=88=90pipeline-?= =?UTF-8?q?llm=E6=A8=A1=E5=9E=8B=E6=B2=BB=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pipeline_app.py: load_llm() try/except兜底加载 - build.sh: clone/pip install/CRUD生成/wwwroot软链 四处枚举加pipeline-llm - create_tables.py: 执行模块手写幂等DDL(8张llm_表,不走json2ddl避DEFAULT引号bug) - import_init.py: 注册appcodes字典; rp.json: /pipeline-llm/** → logined - index.ui主菜单: 加「模型治理」项(/pipeline-llm, TabPanel) --- app/pipeline_app.py | 6 +++++ build.sh | 8 +++--- conf/rp.json | 55 +++++++++++++++++++++++++++------------- scripts/create_tables.py | 19 ++++++++++++++ scripts/import_init.py | 1 + wwwroot/index.ui | 6 +++++ 6 files changed, 73 insertions(+), 22 deletions(-) diff --git a/app/pipeline_app.py b/app/pipeline_app.py index 146819b..a642b09 100644 --- a/app/pipeline_app.py +++ b/app/pipeline_app.py @@ -109,6 +109,11 @@ def init(): from supplychain.init import load_supplychain except ImportError: def load_supplychain(): pass + # pipeline_llm:模型治理(供应商/账号/端点/组织策略/限额限流/双维度记账) + try: + from pipeline_llm.init import load_llm + except ImportError: + def load_llm(): pass set_globalvariable() ServerEnv().get_module_dbname = get_module_dbname @@ -129,6 +134,7 @@ def init(): load_product_management() # 产品层:依赖资源模块的 product_interface load_filemgr() # 文件管理:先于 supplychain(合同附件依赖) load_supplychain() # 供应链:供应商/分销商/折扣 + load_llm() # 模型治理:供应商/账号/端点/组织策略/限额限流/记账 load_pipeline_service() load_pipeline_bidding() # 投标产线能力包(依赖 pipeline_service 的 capability 分发) load_pipeline_opportunity() # 商机产线能力包(数据来自数据爬取平台内网 HTTP) diff --git a/build.sh b/build.sh index f10a84b..7bac270 100644 --- a/build.sh +++ b/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 uapi rag dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding; do +for mod in pipeline-sdlc showcase evaluate pipeline-service pipeline-task tenant app_audit product_management discount pricing unipay smssend accounting uapi rag dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding pipeline-llm; 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 uapi rag dingdingflow pipeline-bidding; 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 dingdingflow pipeline-bidding pipeline-llm; do if [ -d "pkgs/$mod" ]; then "$cdir/py3/bin/pip" install "pkgs/$mod/" 2>&1 | tail -1 fi @@ -91,7 +91,7 @@ fi # 7. Regenerate CRUD from json for all pipeline modules # 注意:凡 json/ 下有 CRUD 定义的模块都必须在列——漏掉则页面从未生成, # 菜单点进去 500(fpath is None)。pricing 曾因遗漏导致定价管理 500。 -for mod in appbase pipeline_core pipeline_ops pipeline_dist pipeline-sdlc rbac dapi accounting uapi rag dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding pricing; do +for mod in appbase pipeline_core pipeline_ops pipeline_dist pipeline-sdlc rbac dapi accounting uapi rag dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding pricing pipeline-llm; do json_dir="pkgs/$mod/json" models_dir="pkgs/$mod/models" wwwroot_dir="pkgs/$mod/wwwroot" @@ -104,7 +104,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 uapi rag dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding; 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 dingdingflow account_resource storage_resource filemgr supplychain pipeline-bidding pipeline-llm; do src="pkgs/$mod/wwwroot" dst="wwwroot/$mod" if [ -d "$src" ]; then diff --git a/conf/rp.json b/conf/rp.json index 320b70d..dafd085 100644 --- a/conf/rp.json +++ b/conf/rp.json @@ -21,25 +21,44 @@ "/accounting/api/fetch_forex_rates.dspy" ], "logined": [ - "/pipeline-sdlc", "/pipeline-sdlc/**", - "/product_management", "/product_management/**", - "/discount", "/discount/**", - "/pricing", "/pricing/**", - "/unipay", "/unipay/**", - "/appbase", "/appbase/**", - "/showcase", "/showcase/**", - "/tenant", "/tenant/**", - "/pipeline_core", "/pipeline_core/**", - "/pipeline_ops", "/pipeline_ops/**", - "/pipeline_dist", "/pipeline_dist/**", - "/pipeline_task", "/pipeline_task/**", - "/app_audit", "/app_audit/**", - "/office", "/office/**", - "/accounting", "/accounting/**" + "/pipeline-sdlc", + "/pipeline-sdlc/**", + "/product_management", + "/product_management/**", + "/discount", + "/discount/**", + "/pricing", + "/pricing/**", + "/unipay", + "/unipay/**", + "/appbase", + "/appbase/**", + "/showcase", + "/showcase/**", + "/tenant", + "/tenant/**", + "/pipeline_core", + "/pipeline_core/**", + "/pipeline_ops", + "/pipeline_ops/**", + "/pipeline_dist", + "/pipeline_dist/**", + "/pipeline_task", + "/pipeline_task/**", + "/app_audit", + "/app_audit/**", + "/office", + "/office/**", + "/accounting", + "/accounting/**", + "/pipeline-llm", + "/pipeline-llm/**" ], "owner.superuser": [ - "/rbac", "/rbac/**", - "/dapi", "/dapi/**" + "/rbac", + "/rbac/**", + "/dapi", + "/dapi/**" ] } -} +} \ No newline at end of file diff --git a/scripts/create_tables.py b/scripts/create_tables.py index 87b825a..cf2b5c0 100644 --- a/scripts/create_tables.py +++ b/scripts/create_tables.py @@ -344,6 +344,25 @@ async def main(): except Exception as e: print(f' WARN: sd_features ensure failed: {e}') + # pipeline-llm 模型治理表(8 张,llm_ 前缀)——模块自带手写幂等 DDL(mysql.ddl.sql), + # 不走 json2ddl(模型定义含 'active' 等带引号默认值,会触发 DEFAULT ''N'' bug) + try: + _llm_ddl_path = os.path.join(ROOT_DIR, 'pkgs', 'pipeline-llm', 'mysql.ddl.sql') + if os.path.isfile(_llm_ddl_path): + with open(_llm_ddl_path, 'r', encoding='utf-8') as _f: + _llm_ddl = _f.read() + _n = 0 + for _stmt in _llm_ddl.split(';'): + _stmt = _stmt.strip() + if _stmt and not _stmt.startswith('--'): + await sor.execute(_stmt, {}) + _n += 1 + print(f' tables: pipeline-llm ensured ({_n} statements, idempotent)') + else: + print(' WARN: pkgs/pipeline-llm/mysql.ddl.sql not found (skip llm_ tables)') + except Exception as e: + print(f' WARN: pipeline-llm tables ensure failed: {e}') + # pipeline-service v2 运行时表(原启动时建,现迁到部署期幂等建表) try: for ddl in _V2_RUNTIME_TABLES: diff --git a/scripts/import_init.py b/scripts/import_init.py index 4c1374f..1e6127f 100644 --- a/scripts/import_init.py +++ b/scripts/import_init.py @@ -31,6 +31,7 @@ INIT_MODULES = [ ('rbac', 'pkgs/rbac/init/data.json'), ('accounting', 'pkgs/accounting/init/data.json'), ('pipeline-bidding', 'pkgs/pipeline-bidding/init/data.json'), + ('pipeline-llm', 'pkgs/pipeline-llm/init/data.json'), ] diff --git a/wwwroot/index.ui b/wwwroot/index.ui index b55d313..1f95c8c 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -187,6 +187,12 @@ "icon": "", "script": "this.open_tab({name:'llm_manage',label:'模型管理',url:'/pipeline_core/llm',removable:true})" }, + { + "name": "llm_governance", + "label": "模型治理", + "icon": "", + "script": "this.open_tab({name:'llm_governance',label:'模型治理',url:'/pipeline-llm',removable:true})" + }, { "name": "generic_agent", "label": "通用助手",