@absolutejs/rag 0.1.3 → 0.3.0
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/adapter-kit/index.js +52 -19
- package/dist/adapter-kit/index.js.map +3 -3
- package/dist/index.js +53 -19
- package/dist/index.js.map +3 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/ingestion/ingestion.d.ts +15 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15103,6 +15103,8 @@ var emailStructureUnits = (value, metadata) => {
|
|
|
15103
15103
|
return "Forwarded Headers";
|
|
15104
15104
|
case "quoted_history":
|
|
15105
15105
|
return "Quoted History";
|
|
15106
|
+
case "signature":
|
|
15107
|
+
return "Signature";
|
|
15106
15108
|
}
|
|
15107
15109
|
};
|
|
15108
15110
|
const familyKeyBase = threadTopic || from || "Email Message";
|
|
@@ -17311,15 +17313,30 @@ var EMAIL_FORWARDED_HEADER_PATTERN = /^(?:from|sent|to|cc|bcc|subject|date|reply
|
|
|
17311
17313
|
var EMAIL_FORWARDED_SEPARATOR_PATTERN = /^-{2,}\s*forwarded message\s*-{2,}$/i;
|
|
17312
17314
|
var EMAIL_HTML_QUOTE_OPEN_TOKEN = "[[ABS_EMAIL_QUOTE_OPEN]]";
|
|
17313
17315
|
var EMAIL_HTML_QUOTE_CLOSE_TOKEN = "[[ABS_EMAIL_QUOTE_CLOSE]]";
|
|
17316
|
+
var EMAIL_ATTRIBUTION_PATTERNS = [
|
|
17317
|
+
/^on\s.+\bwrote:$/iu,
|
|
17318
|
+
/^on\s.+\bat\s.+\bwrote:$/iu,
|
|
17319
|
+
/^-+\s*original message\s*-+$/iu,
|
|
17320
|
+
/^_{5,}$/u,
|
|
17321
|
+
/^el\s.+\bescribi\u00F3:$/iu,
|
|
17322
|
+
/^le\s.+\ba \u00E9crit\s*:$/iu
|
|
17323
|
+
];
|
|
17324
|
+
var EMAIL_SIGNATURE_DELIMITER = /^--\s?$/u;
|
|
17314
17325
|
var classifyEmailBodyLine = (line, currentKind) => {
|
|
17315
17326
|
const trimmed = line.trim();
|
|
17316
17327
|
if (!trimmed) {
|
|
17317
17328
|
return currentKind;
|
|
17318
17329
|
}
|
|
17330
|
+
if (currentKind === "signature") {
|
|
17331
|
+
return "signature";
|
|
17332
|
+
}
|
|
17333
|
+
if (EMAIL_SIGNATURE_DELIMITER.test(line)) {
|
|
17334
|
+
return "signature";
|
|
17335
|
+
}
|
|
17319
17336
|
if (/^>+/.test(trimmed)) {
|
|
17320
17337
|
return "quoted_history";
|
|
17321
17338
|
}
|
|
17322
|
-
if (
|
|
17339
|
+
if (EMAIL_ATTRIBUTION_PATTERNS.some((pattern) => pattern.test(trimmed))) {
|
|
17323
17340
|
return "quoted_history";
|
|
17324
17341
|
}
|
|
17325
17342
|
if (EMAIL_FORWARDED_SEPARATOR_PATTERN.test(trimmed)) {
|
|
@@ -17507,16 +17524,8 @@ var scoreEmailBodyCandidate = (candidate) => {
|
|
|
17507
17524
|
return Number.NEGATIVE_INFINITY;
|
|
17508
17525
|
}
|
|
17509
17526
|
const sections = parseEmailBodySections(candidate);
|
|
17510
|
-
const
|
|
17511
|
-
|
|
17512
|
-
return score + 8;
|
|
17513
|
-
}
|
|
17514
|
-
if (section.kind === "quoted_history") {
|
|
17515
|
-
return score + 6 + (section.quotedDepth ?? 0);
|
|
17516
|
-
}
|
|
17517
|
-
return score + 1;
|
|
17518
|
-
}, 0);
|
|
17519
|
-
return structuralScore * 10 + Math.min(candidate.length, 5000) / 100;
|
|
17527
|
+
const authoredChars = sections.filter((section) => section.kind === "authored_text").reduce((total, section) => total + section.text.trim().length, 0);
|
|
17528
|
+
return authoredChars * 10 + Math.min(candidate.length, 5000) / 1000;
|
|
17520
17529
|
};
|
|
17521
17530
|
var choosePreferredEmailBodyText = (htmlText, plainText) => {
|
|
17522
17531
|
const htmlScore = scoreEmailBodyCandidate(htmlText);
|
|
@@ -17613,6 +17622,12 @@ var parseEmailMimeParts = (body, contentType) => {
|
|
|
17613
17622
|
bodyText
|
|
17614
17623
|
};
|
|
17615
17624
|
};
|
|
17625
|
+
var authoredEmailText = (text) => {
|
|
17626
|
+
const authored = parseEmailBodySections(text).filter((section) => section.kind === "authored_text").map((section) => section.text.trim()).filter(Boolean).join(`
|
|
17627
|
+
|
|
17628
|
+
`).trim();
|
|
17629
|
+
return authored || text;
|
|
17630
|
+
};
|
|
17616
17631
|
var extractEmailText = (raw) => {
|
|
17617
17632
|
const { body, headerBlock } = splitEmailMessage(raw);
|
|
17618
17633
|
const headers = parseHeaderBlock(headerBlock);
|
|
@@ -19308,7 +19323,10 @@ var sourceAwareUnits = (document, format, normalizedText) => {
|
|
|
19308
19323
|
}
|
|
19309
19324
|
};
|
|
19310
19325
|
var overlapTail = (value, overlap) => {
|
|
19311
|
-
if (overlap <= 0
|
|
19326
|
+
if (overlap <= 0) {
|
|
19327
|
+
return "";
|
|
19328
|
+
}
|
|
19329
|
+
if (value.length <= overlap) {
|
|
19312
19330
|
return value;
|
|
19313
19331
|
}
|
|
19314
19332
|
const candidate = value.slice(-overlap);
|
|
@@ -19323,11 +19341,16 @@ var chunkFromUnits = (units, maxChunkLength, chunkOverlap, minChunkLength) => {
|
|
|
19323
19341
|
};
|
|
19324
19342
|
const mergeSmallChunk = (merged2, chunk) => {
|
|
19325
19343
|
const last = merged2[merged2.length - 1];
|
|
19326
|
-
if (
|
|
19344
|
+
if (last === undefined || chunk.length >= minChunkLength) {
|
|
19345
|
+
merged2.push(chunk);
|
|
19346
|
+
return;
|
|
19347
|
+
}
|
|
19348
|
+
const candidate = normalizeWhitespace(`${last} ${chunk}`);
|
|
19349
|
+
if (candidate.length > maxChunkLength) {
|
|
19327
19350
|
merged2.push(chunk);
|
|
19328
19351
|
return;
|
|
19329
19352
|
}
|
|
19330
|
-
merged2[merged2.length - 1] =
|
|
19353
|
+
merged2[merged2.length - 1] = candidate;
|
|
19331
19354
|
};
|
|
19332
19355
|
const appendUnitToChunk = (trimmed) => {
|
|
19333
19356
|
if (!current) {
|
|
@@ -19348,11 +19371,21 @@ var chunkFromUnits = (units, maxChunkLength, chunkOverlap, minChunkLength) => {
|
|
|
19348
19371
|
const carry = overlapTail(current, chunkOverlap);
|
|
19349
19372
|
current = carry.length > 0 ? `${carry} ${trimmed}`.trim() : trimmed;
|
|
19350
19373
|
};
|
|
19374
|
+
const explodeOversized = (unit) => {
|
|
19375
|
+
if (unit.length <= maxChunkLength)
|
|
19376
|
+
return [unit];
|
|
19377
|
+
const sentences = sentenceUnits(unit);
|
|
19378
|
+
if (sentences.length > 1)
|
|
19379
|
+
return sentences.flatMap(explodeOversized);
|
|
19380
|
+
return fixedUnits(unit, maxChunkLength);
|
|
19381
|
+
};
|
|
19351
19382
|
for (const unit of units) {
|
|
19352
|
-
const
|
|
19353
|
-
|
|
19354
|
-
|
|
19355
|
-
|
|
19383
|
+
for (const piece of explodeOversized(unit.trim())) {
|
|
19384
|
+
const trimmed = piece.trim();
|
|
19385
|
+
if (!trimmed)
|
|
19386
|
+
continue;
|
|
19387
|
+
appendUnitToChunk(trimmed);
|
|
19388
|
+
}
|
|
19356
19389
|
}
|
|
19357
19390
|
if (current) {
|
|
19358
19391
|
appendChunk(current);
|
|
@@ -36328,6 +36361,7 @@ export {
|
|
|
36328
36361
|
buildRAGAdminJobPresentation,
|
|
36329
36362
|
buildRAGAdminActionPresentations,
|
|
36330
36363
|
buildRAGAdminActionPresentation,
|
|
36364
|
+
authoredEmailText,
|
|
36331
36365
|
applyRAGSQLiteStoreMigrations,
|
|
36332
36366
|
applyRAGReranking,
|
|
36333
36367
|
applyRAGQueryTransform,
|
|
@@ -36337,5 +36371,5 @@ export {
|
|
|
36337
36371
|
addRAGEvaluationSuiteCase
|
|
36338
36372
|
};
|
|
36339
36373
|
|
|
36340
|
-
//# debugId=
|
|
36374
|
+
//# debugId=176571A7F3C6808164756E2164756E21
|
|
36341
36375
|
//# sourceMappingURL=index.js.map
|