feat: add online FAQ/KB sync without old bridge

This commit is contained in:
wangliang
2026-10-23 11:29:43 +08:00
parent f526696f93
commit 81b49c9350
24 changed files with 1793 additions and 5 deletions
+33 -1
View File
@@ -191,7 +191,7 @@ docker exec crmnew-postgres psql -U crmnew -d bridge -tAc \
预期:
```
361 | 292 | 69
367 | 296 | 71
```
然后把测试环境 `.env` 的 `RAG_PG_URL` 指向该库,例如:
@@ -203,6 +203,38 @@ RAG_PG_URL=postgres://crmnew:<password>@postgres:5432/bridge
> 快照文件:`deploy/seeds/kb_docs.sql.gz`(只包含 `kb_docs` 知识库,不含邮件/客户数据)
> 当前环境如需重新生成:`bash scripts/export-kb-snapshot.sh`
#### 在线 FAQ 同步(不依赖旧 bridge)
测试/生产如果网络可以访问官网 FAQ,可直接:
```bash
# 在宿主机执行时,RAG_PG_URL 用宿主机可达地址
RAG_PG_URL=postgres://crmnew:<password>@127.0.0.1:5440/bridge \
node scripts/sync-kb-online.js
# 如果脚本跑在 bridge 容器内,则用容器内地址
# RAG_PG_URL=postgres://crmnew:<password>@postgres:5432/bridge
```
建议 cron 每周一次:
```cron
0 3 * * 1 cd /home/dev/code/crm-new && RAG_PG_URL=... node scripts/sync-kb-online.js
```
如果官网抓取被 WAF 拦截,可先用本地源文件重建:
```bash
node scripts/sync-kb-online.js --local-only --force
```
注意:
- 需要 `RAG_PG_URL` 指向目标库
- 需要 `EMB_*`(DashScope embedding)
- 旧的 `kb_docs` 会备份为 `kb_docs_v<timestamp>`
- `bridge/kb/11-site-map.md` 目前是静态类目地图,不随官网自动更新
#### 全量商品页站点地图
```bash