问题描述
按照 README 完成安装并启动服务后(npm run dev),WebUI 可以正常打开,但上传文档后处理失败,提示:
entity_types seed data is missing; run npm run seed
执行 npm run seed 后命令立即返回,无输出、无报错,但数据实际并未插入。
环境
- OS: Windows 11 + PowerShell
- Node.js: 20+
- SAG 版本: main 分支最新
- 数据库: Docker (
pgvector/pgvector:pg16)
根本原因
npm run seed 静默失败:在 Windows PowerShell 环境下,tsx src/db/seed.ts 执行时可能因路径解析或模块加载问题静默退出,没有成功插入数据,也没有任何错误输出。
- 缺少
entity_types 基础数据:SAG 的文档处理流水线(分块 → 实体抽取 → 事件抽取)依赖 entity_types 表中的预定义实体类型(time、location、person、organization、subject、product、metric)。该表在 db:migrate 阶段创建,但数据需要 seed 步骤插入。
解决方案(手动插入 Seed 数据)
由于 npm run seed 在 Windows 环境下无法正常工作,改为通过 docker exec 直接执行 SQL:
# 进入 PostgreSQL 容器,直接插入 entity_types 种子数据
docker exec sag_lite_postgres psql -U sag_lite -d sag_lite -c "INSERT INTO entity_types (id, type, name, description, weight, similarity_threshold) VALUES ('30000000-0000-0000-0000-000000000001', 'time', 'time', 'Time points, periods, dates, years and temporal expressions.', 1.0, 0.9), ('30000000-0000-0000-0000-000000000002', 'location', 'location', 'Countries, cities, regions, places and physical locations.', 1.0, 0.75), ('30000000-0000-0000-0000-000000000003', 'person', 'person', 'People and named individuals.', 1.2, 0.8), ('30000000-0000-0000-0000-000000000004', 'organization', 'organization', 'Companies, institutions, teams and organizations.', 1.1, 0.8), ('30000000-0000-0000-0000-000000000005', 'subject', 'subject', 'Main topics, concepts and subjects.', 1.5, 0.78), ('30000000-0000-0000-0000-000000000006', 'product', 'product', 'Products, services, projects and named offerings.', 1.1, 0.8), ('30000000-0000-0000-0000-000000000007', 'metric', 'metric', 'Numbers, metrics, measurements, amounts and statistics.', 1.2, 0.85) ON CONFLICT DO NOTHING;"
验证插入成功:
docker exec sag_lite_postgres psql -U sag_lite -d sag_lite -c "SELECT * FROM entity_types;"
建议修复
- 增强
seed.ts 的跨平台兼容性:当前 npm run seed 在 Windows PowerShell 下静默失败,建议增加日志输出和错误捕获,方便排查。
- 在文档处理前自动检查 seed 数据:如果
entity_types 为空,自动执行 seed 而不是仅报错提示。
- README 补充 Windows 环境注意事项:针对 Windows 用户补充手动 seed 的备选方案。
问题描述
按照 README 完成安装并启动服务后(
npm run dev),WebUI 可以正常打开,但上传文档后处理失败,提示:执行
npm run seed后命令立即返回,无输出、无报错,但数据实际并未插入。环境
pgvector/pgvector:pg16)根本原因
npm run seed静默失败:在 Windows PowerShell 环境下,tsx src/db/seed.ts执行时可能因路径解析或模块加载问题静默退出,没有成功插入数据,也没有任何错误输出。entity_types基础数据:SAG 的文档处理流水线(分块 → 实体抽取 → 事件抽取)依赖entity_types表中的预定义实体类型(time、location、person、organization、subject、product、metric)。该表在db:migrate阶段创建,但数据需要seed步骤插入。解决方案(手动插入 Seed 数据)
由于
npm run seed在 Windows 环境下无法正常工作,改为通过docker exec直接执行 SQL:# 进入 PostgreSQL 容器,直接插入 entity_types 种子数据 docker exec sag_lite_postgres psql -U sag_lite -d sag_lite -c "INSERT INTO entity_types (id, type, name, description, weight, similarity_threshold) VALUES ('30000000-0000-0000-0000-000000000001', 'time', 'time', 'Time points, periods, dates, years and temporal expressions.', 1.0, 0.9), ('30000000-0000-0000-0000-000000000002', 'location', 'location', 'Countries, cities, regions, places and physical locations.', 1.0, 0.75), ('30000000-0000-0000-0000-000000000003', 'person', 'person', 'People and named individuals.', 1.2, 0.8), ('30000000-0000-0000-0000-000000000004', 'organization', 'organization', 'Companies, institutions, teams and organizations.', 1.1, 0.8), ('30000000-0000-0000-0000-000000000005', 'subject', 'subject', 'Main topics, concepts and subjects.', 1.5, 0.78), ('30000000-0000-0000-0000-000000000006', 'product', 'product', 'Products, services, projects and named offerings.', 1.1, 0.8), ('30000000-0000-0000-0000-000000000007', 'metric', 'metric', 'Numbers, metrics, measurements, amounts and statistics.', 1.2, 0.85) ON CONFLICT DO NOTHING;"验证插入成功:
建议修复
seed.ts的跨平台兼容性:当前npm run seed在 Windows PowerShell 下静默失败,建议增加日志输出和错误捕获,方便排查。entity_types为空,自动执行 seed 而不是仅报错提示。