feat: add portable KB snapshot for environments without old bridge

This commit is contained in:
wangliang
2026-10-23 11:19:49 +08:00
parent a161a0eee9
commit f526696f93
7 changed files with 118 additions and 7 deletions
+39 -3
View File
@@ -162,10 +162,9 @@ node scripts/configure-email.js
### 6.3 数据准备
```bash
# 全量商品页站点地图(每周/商品大更新后)
node scripts/build-site-map.js www us
#### 有旧 bridge / 旧 products 库时
```bash
# 重建 KB parent-child 索引(KB 更新后;会先备份旧表)
bash scripts/rebuild-kb-index.sh
@@ -173,6 +172,43 @@ bash scripts/rebuild-kb-index.sh
node scripts/upgrade-kb-schema.js
```
#### 测试/生产没有旧 bridge 时(推荐)
不要运行 `rebuild-kb-index.sh`。直接导入仓库里的 KB 快照:
```bash
# 默认导入到 crmnew-postgres / bridge 库
bash scripts/import-kb-snapshot.sh
# 或导入到 products 库
TARGET_PG_DB=products bash scripts/import-kb-snapshot.sh
# 验证
docker exec crmnew-postgres psql -U crmnew -d bridge -tAc \
"select count(*), count(*) filter (where chunk_type='parent'), count(*) filter (where chunk_type='child') from kb_docs;"
```
预期:
```
361 | 292 | 69
```
然后把测试环境 `.env` 的 `RAG_PG_URL` 指向该库,例如:
```env
RAG_PG_URL=postgres://crmnew:<password>@postgres:5432/bridge
```
> 快照文件:`deploy/seeds/kb_docs.sql.gz`(只包含 `kb_docs` 知识库,不含邮件/客户数据)
> 当前环境如需重新生成:`bash scripts/export-kb-snapshot.sh`
#### 全量商品页站点地图
```bash
node scripts/build-site-map.js www us
```
### 6.4 RPC 隧道(仅本地开发)
> 测试/生产不需要这一步;直接配置内网 RPC 地址即可。