S0: bioflow_service 三 MCP 端点(gene-family/rnaseq/extension) + 源文件获取/预处理 S1: QA bioflow_agent 前门 router + capabilities.yaml 三条目 + 熔断 S2: card_result 回填 + 多轮记忆 + session↔job 绑定 S3: 前端 TAB 双信号 + 卡片辅助化 + 进度块只读 + 删除直连 S4: 扩展子系统对话化(第三能力单元) S5: toggle_bioflow.sh 装卸 + SettingsPanel 三开关 S6: 多配置回归 + 对话剧本测试手册
142 lines
5.1 KiB
Bash
Executable File
142 lines
5.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# deploy/toggle_bioflow.sh —— 生信能力按需装卸(热,不重启 QA)+ bioflow_service 启停 + 注册状态自检。
|
||
#
|
||
# 用法:
|
||
# bash deploy/toggle_bioflow.sh <gene-family|rnaseq|extension|all> <on|off>
|
||
#
|
||
# 原理:
|
||
# - 能力装卸经 BFF POST /api/capabilities/install(透传 QA install_manager,热加载生效不重启 QA)
|
||
# - on = register(manifest 校验 + 原子写 capabilities.yaml + registry 差分刷新)
|
||
# - off = unregister(按 name 移除能力段,其余能力不受影响)
|
||
# - 自检 = GET /api/capabilities 的 installed 数组是否含对应能力
|
||
# - bioflow_service 启停:全部能力关闭时停 8098;任一开启时启动 8098
|
||
# - 卸载活跃任务:三表已持久化,服务恢复后 runner.recover 续跑;QA 侧按「生信服务未启动」降级话术
|
||
set -uo pipefail
|
||
|
||
BFF="http://127.0.0.1:8090"
|
||
BIOFLOW_SERVICE_DIR="/home/xzq/5090/teamWorkspace/zh/PlantAI-rag-new/bioflow_service"
|
||
PY="/home/xzq/5090/teamWorkspace/zh/plantai-rag-new-venv/bin/python"
|
||
BIOFLOW_PORT="${BIOFLOW_PORT:-8098}"
|
||
|
||
CAP="${1:-}"
|
||
ACTION="${2:-}"
|
||
|
||
CAPS=(gene-family rnaseq extension)
|
||
|
||
usage() {
|
||
echo "用法: $0 <gene-family|rnaseq|extension|all> <on|off>" >&2
|
||
exit 2
|
||
}
|
||
|
||
# capability key -> registry 能力名
|
||
cap_name() {
|
||
case "$1" in
|
||
gene-family) echo "bioflow-gene-family" ;;
|
||
rnaseq) echo "bioflow-rnaseq" ;;
|
||
extension) echo "bioflow-extension" ;;
|
||
*) usage ;;
|
||
esac
|
||
}
|
||
|
||
# capability key -> register manifest YAML(与 agent/qa/configs/capabilities.yaml 一致)
|
||
manifest() {
|
||
case "$1" in
|
||
gene-family) cat <<'YAML'
|
||
capabilities:
|
||
- name: bioflow-gene-family
|
||
provider: mcp
|
||
permission: read_only
|
||
description: 基因家族分析(路径规划/建任务/参数确认/文件获取与预处理/状态查询),自然语言触发
|
||
session_default: true
|
||
nl_triggers: [基因家族, 家族成员, 亚家族, 系统发育, 建树, 进化树, 保守基序, motif, 结构域, 基因结构, 共线性, Ka/Ks, 选择压力, 组合证据]
|
||
mcp:
|
||
url: http://127.0.0.1:8098/mcp/gene-family/
|
||
prompt_pack:
|
||
file: bioflow_gene_family_agent_rules.md
|
||
YAML
|
||
;;
|
||
rnaseq) cat <<'YAML'
|
||
capabilities:
|
||
- name: bioflow-rnaseq
|
||
provider: mcp
|
||
permission: read_only
|
||
description: 转录组分析(实验设计确认/样本配置/路径规划/建任务/差异表达/富集),自然语言触发
|
||
session_default: true
|
||
nl_triggers: [转录组, RNA-seq, RNAseq, rnaseq, 差异表达, 表达定量, 富集, WGCNA, GSEA, 实验设计, fastq]
|
||
mcp:
|
||
url: http://127.0.0.1:8098/mcp/rnaseq/
|
||
prompt_pack:
|
||
file: bioflow_rnaseq_agent_rules.md
|
||
YAML
|
||
;;
|
||
extension) cat <<'YAML'
|
||
capabilities:
|
||
- name: bioflow-extension
|
||
provider: mcp
|
||
permission: read_only
|
||
description: 用户自定义扩展分析(创建/转换/试运行/校验/发布/运行),自然语言触发
|
||
session_default: true
|
||
nl_triggers: [扩展, 拓展分析, 扩展分析, 自定义分析, 分析模板, 分析脚本, 分析工具]
|
||
mcp:
|
||
url: http://127.0.0.1:8098/mcp/extension/
|
||
prompt_pack:
|
||
file: bioflow_extension_agent_rules.md
|
||
YAML
|
||
;;
|
||
*) usage ;;
|
||
esac
|
||
}
|
||
|
||
[ -n "$CAP" ] && [ -n "$ACTION" ] || usage
|
||
[ "$ACTION" = "on" ] || [ "$ACTION" = "off" ] || usage
|
||
if [ "$CAP" != "all" ]; then
|
||
cap_name "$CAP" >/dev/null 2>&1 || usage
|
||
fi
|
||
|
||
# 1. 逐能力 register/unregister(热加载不重启 QA)
|
||
targets=("$CAP")
|
||
[ "$CAP" = "all" ] && targets=("${CAPS[@]}")
|
||
for key in "${targets[@]}"; do
|
||
name="$(cap_name "$key")"
|
||
if [ "$ACTION" = "on" ]; then
|
||
body="$(manifest "$key")"
|
||
resp=$(curl -s -m 30 -X POST "$BFF/api/capabilities/install" \
|
||
-H 'Content-Type: application/json' \
|
||
-d "$(python3 -c 'import json,sys; print(json.dumps({"action":"register","manifest":sys.stdin.read()}))' <<<"$body")")
|
||
else
|
||
resp=$(curl -s -m 30 -X POST "$BFF/api/capabilities/install" \
|
||
-H 'Content-Type: application/json' \
|
||
-d "{\"action\":\"unregister\",\"name\":\"$name\"}")
|
||
fi
|
||
echo "[$ACTION] $name -> $(echo "$resp" | head -c 300)"
|
||
done
|
||
|
||
# 2. 自检:GET /api/capabilities 的 installed 数组
|
||
installed=$(curl -s -m 10 "$BFF/api/capabilities")
|
||
echo "注册状态: $(echo "$installed" | python3 -c 'import json,sys; d=json.load(sys.stdin); print([i.get("name") for i in d.get("installed") or []])' 2>/dev/null || echo 'parse-fail')"
|
||
|
||
# 3. bioflow_service 按需启停:任一能力开启则启动,全部关闭则停止
|
||
any_on=false
|
||
for key in "${CAPS[@]}"; do
|
||
name="$(cap_name "$key")"
|
||
if echo "$installed" | grep -q "\"$name\""; then
|
||
any_on=true
|
||
fi
|
||
done
|
||
|
||
if [ "$any_on" = true ]; then
|
||
if ! lsof -ti tcp:$BIOFLOW_PORT -sTCP:LISTEN >/dev/null 2>&1; then
|
||
echo "启动 bioflow_service :$BIOFLOW_PORT"
|
||
( cd "$BIOFLOW_SERVICE_DIR" && setsid "$PY" -m uvicorn app.main:app --host 127.0.0.1 --port "$BIOFLOW_PORT" \
|
||
> /tmp/plantai-bioflow.log 2>&1 < /dev/null & ) && disown -a
|
||
sleep 2
|
||
fi
|
||
curl -s -m 8 "http://127.0.0.1:$BIOFLOW_PORT/api/bioflow/health" | head -c 150
|
||
echo
|
||
else
|
||
echo "全部能力已卸载:停止 bioflow_service :$BIOFLOW_PORT"
|
||
kill $(lsof -ti tcp:$BIOFLOW_PORT -sTCP:LISTEN) 2>/dev/null || true
|
||
fi
|
||
|
||
echo "DONE"
|