UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

22 lines • 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.byParagraph = void 0; const constants_js_1 = require("./constants.js"); const shared_js_1 = require("./shared.js"); function byParagraph(options = {}) { const maxChars = options.maxChars ?? constants_js_1.DEFAULT_MAX_CHARS; const overlapChars = options.overlapChars ?? constants_js_1.DEFAULT_OVERLAP_CHARS; const minChars = (0, shared_js_1.resolveMinChars)(options.minChars, maxChars); return { name: 'byParagraph', split(doc) { const paragraphs = (0, shared_js_1.paragraphSpans)(doc.text); const packed = (0, shared_js_1.packSpans)(paragraphs, maxChars); const cut = packed.flatMap((span) => span.end - span.start > maxChars ? (0, shared_js_1.hardCut)(span, maxChars, overlapChars) : [span]); const floored = (0, shared_js_1.mergeShortSpansForward)((0, shared_js_1.foldRunts)(cut), minChars); return (0, shared_js_1.toPieces)(doc, (0, shared_js_1.applyOverlap)(floored, overlapChars)); }, }; } exports.byParagraph = byParagraph; //# sourceMappingURL=byParagraph.js.map