跳到主要内容

RAG

RAG 包重命名了分块参数,并缩小了其类型范围。

已变更
已变更的直接链接

keepSeparator 改为 separatorPosition
keepseparator-to-separatorposition的直接链接

keepSeparator 参数已重命名为 separatorPosition,类型也得到简化。旧参数使用容易混淆的 boolean | 'start' | 'end' 类型,其中 true 实际上是 'start' 的别名。新参数使用明确的 'start' | 'end' 值;省略该参数时会丢弃分隔符。

迁移时,请按照以下映射将 keepSeparator 替换为 separatorPosition

旧值新值
keepSeparator: trueseparatorPosition: 'start'
keepSeparator: 'start'separatorPosition: 'start'
keepSeparator: 'end'separatorPosition: 'end'
keepSeparator: false移除该参数
省略参数无需更改
await doc.chunk({
strategy: 'character',
separator: '.',
- keepSeparator: true,
+ separatorPosition: 'start',
});

await doc.chunk({
strategy: 'character',
separator: '.',
- keepSeparator: 'end',
+ separatorPosition: 'end',
});

await doc.chunk({
strategy: 'character',
separator: '.',
- keepSeparator: false,
+ // Parameter removed - separator is discarded by default
});