@mastra/rag 2.6.5-alpha.0 → 2.6.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/document/transformers/sentence.d.ts.map +1 -1
- package/dist/index.cjs +22 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentence.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/sentence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IACnC,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAExC,YAAY,OAAO,EAAE,oBAAoB,EAoBxC;IAED,OAAO,CAAC,wBAAwB;IA+BhC,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,oBAAoB;IA8B5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;
|
|
1
|
+
{"version":3,"file":"sentence.d.ts","sourceRoot":"","sources":["../../../src/document/transformers/sentence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IACnC,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAExC,YAAY,OAAO,EAAE,oBAAoB,EAoBxC;IAED,OAAO,CAAC,wBAAwB;IA+BhC,OAAO,CAAC,sBAAsB;IAqB9B,OAAO,CAAC,oBAAoB;IA8B5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmEhC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqB/B,OAAO,CAAC,sBAAsB;IAmC9B,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,wBAAwB;IA4BhC,OAAO,CAAC,kBAAkB;IAqB1B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE,CAQ9C;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -5544,35 +5544,44 @@ var SentenceTransformer = class extends TextTransformer {
|
|
|
5544
5544
|
const chunks = [];
|
|
5545
5545
|
let currentChunk = [];
|
|
5546
5546
|
let currentSize = 0;
|
|
5547
|
+
let carriedCount = 0;
|
|
5547
5548
|
const separator = " ";
|
|
5549
|
+
const sepLength = this.lengthFunction(separator);
|
|
5548
5550
|
for (const sentence of sentences) {
|
|
5549
5551
|
const sentenceLength = this.lengthFunction(sentence);
|
|
5550
|
-
const separatorLength = currentChunk.length > 0 ? this.lengthFunction(separator) : 0;
|
|
5551
|
-
const totalLength = currentSize + sentenceLength + separatorLength;
|
|
5552
5552
|
if (sentenceLength > this.maxSize) {
|
|
5553
|
-
if (currentChunk.length >
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
}
|
|
5553
|
+
if (currentChunk.length > carriedCount) chunks.push(currentChunk.join(separator));
|
|
5554
|
+
currentChunk = [];
|
|
5555
|
+
currentSize = 0;
|
|
5556
|
+
carriedCount = 0;
|
|
5558
5557
|
const fallbackChunks = this.handleOversizedSentence(sentence);
|
|
5559
5558
|
chunks.push(...fallbackChunks);
|
|
5560
5559
|
continue;
|
|
5561
5560
|
}
|
|
5562
|
-
if (currentChunk.length > 0 &&
|
|
5563
|
-
chunks.push(currentChunk.join(separator));
|
|
5564
|
-
|
|
5565
|
-
|
|
5561
|
+
if (currentChunk.length > 0 && currentSize + sepLength + sentenceLength > this.maxSize) {
|
|
5562
|
+
if (currentChunk.length > carriedCount) chunks.push(currentChunk.join(separator));
|
|
5563
|
+
const overlapSentences = this.calculateSentenceOverlap(currentChunk);
|
|
5564
|
+
let overlapSize = this.calculateChunkSize(overlapSentences);
|
|
5565
|
+
let start = 0;
|
|
5566
|
+
while (start < overlapSentences.length && overlapSize + sepLength + sentenceLength > this.maxSize) {
|
|
5567
|
+
overlapSize -= this.lengthFunction(overlapSentences[start]);
|
|
5568
|
+
if (start < overlapSentences.length - 1) overlapSize -= sepLength;
|
|
5569
|
+
start++;
|
|
5570
|
+
}
|
|
5571
|
+
currentChunk = overlapSentences.slice(start);
|
|
5572
|
+
carriedCount = currentChunk.length;
|
|
5573
|
+
currentSize = currentChunk.length > 0 ? overlapSize : 0;
|
|
5566
5574
|
}
|
|
5575
|
+
currentSize += sentenceLength + (currentChunk.length > 0 ? sepLength : 0);
|
|
5567
5576
|
currentChunk.push(sentence);
|
|
5568
|
-
currentSize += sentenceLength + separatorLength;
|
|
5569
5577
|
if (currentSize >= this.targetSize) {
|
|
5570
5578
|
chunks.push(currentChunk.join(separator));
|
|
5571
5579
|
currentChunk = this.calculateSentenceOverlap(currentChunk);
|
|
5580
|
+
carriedCount = currentChunk.length;
|
|
5572
5581
|
currentSize = this.calculateChunkSize(currentChunk);
|
|
5573
5582
|
}
|
|
5574
5583
|
}
|
|
5575
|
-
if (currentChunk.length >
|
|
5584
|
+
if (currentChunk.length > carriedCount) chunks.push(currentChunk.join(separator));
|
|
5576
5585
|
return chunks;
|
|
5577
5586
|
}
|
|
5578
5587
|
/**
|