UNPKG

agentfootprint

Version:

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

18 lines • 981 B
import { DEFAULT_MAX_CHARS, DEFAULT_OVERLAP_CHARS } from './constants.js'; import { applyOverlap, foldRunts, hardCut, mergeShortSpansForward, packSpans, paragraphSpans, resolveMinChars, toPieces, } from './shared.js'; export function byParagraph(options = {}) { const maxChars = options.maxChars ?? DEFAULT_MAX_CHARS; const overlapChars = options.overlapChars ?? DEFAULT_OVERLAP_CHARS; const minChars = resolveMinChars(options.minChars, maxChars); return { name: 'byParagraph', split(doc) { const paragraphs = paragraphSpans(doc.text); const packed = packSpans(paragraphs, maxChars); const cut = packed.flatMap((span) => span.end - span.start > maxChars ? hardCut(span, maxChars, overlapChars) : [span]); const floored = mergeShortSpansForward(foldRunts(cut), minChars); return toPieces(doc, applyOverlap(floored, overlapChars)); }, }; } //# sourceMappingURL=byParagraph.js.map