跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

RAG

The RAG package has renamed chunking parameters and narrowed their types.

Changed
Changed的直接链接

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

The keepSeparator parameter has been renamed to separatorPosition with a simplified type. The old parameter had a confusing boolean | 'start' | 'end' type where true was secretly an alias for 'start'. The new parameter uses explicit 'start' | 'end' values, and omitting the parameter discards the separator.

To migrate, replace keepSeparator with separatorPosition using the mapping below:

Old valueNew value
keepSeparator: trueseparatorPosition: 'start'
keepSeparator: 'start'separatorPosition: 'start'
keepSeparator: 'end'separatorPosition: 'end'
keepSeparator: falseRemove the parameter
Parameter omittedNo change needed
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
});
On this page