@customize-agent/knowledge 4.0.19 → 4.0.20
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.
|
@@ -295,9 +295,9 @@ export class TextChunker {
|
|
|
295
295
|
return chunks.flatMap(chunk => this.estimateTokens(chunk) > maxTokens ? this.splitByWindow(chunk, maxTokens, overlapTokens) : [chunk]);
|
|
296
296
|
}
|
|
297
297
|
splitByWindow(text, maxTokens, overlapTokens = 0) {
|
|
298
|
-
if (!/[\s\n\r\t。?!;;.!?,、]/u.test(text) && text.length > maxTokens * 3) {
|
|
299
|
-
const maxChars = Math.max(1, maxTokens
|
|
300
|
-
const overlapChars = Math.max(0, Math.min(Math.floor(maxChars / 2), overlapTokens
|
|
298
|
+
if (!/[\s\n\r\t。?!;;.!?,、]/u.test(text) && text.length > Math.max(2000, maxTokens * 3)) {
|
|
299
|
+
const maxChars = Math.max(1, maxTokens);
|
|
300
|
+
const overlapChars = Math.max(0, Math.min(Math.floor(maxChars / 2), overlapTokens));
|
|
301
301
|
const step = Math.max(1, maxChars - overlapChars);
|
|
302
302
|
const chunks = [];
|
|
303
303
|
for (let start = 0; start < text.length; start += step) {
|