@absolutejs/rag 0.9.0 → 0.11.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/CHANGELOG.md +20 -0
- package/README.md +52 -0
- package/changelog.json +44 -0
- package/dist/adapter-kit/index.js +6 -3
- package/dist/adapter-kit/index.js.map +3 -3
- package/dist/index.js +57 -3
- package/dist/index.js.map +6 -5
- package/dist/src/index.d.ts +1 -0
- package/dist/src/retrieval/quoteReferences.d.ts +13 -0
- package/dist/src/web/index.d.ts +42 -0
- package/dist/src/web/playwright.d.ts +9 -0
- package/dist/src/web/transport.d.ts +22 -0
- package/dist/web/index.js +6741 -0
- package/dist/web/index.js.map +13 -0
- package/dist/web/playwright.js +270 -0
- package/dist/web/playwright.js.map +11 -0
- package/package.json +18 -5
package/dist/index.js
CHANGED
|
@@ -15251,6 +15251,9 @@ var inferFormatFromName = (value) => {
|
|
|
15251
15251
|
};
|
|
15252
15252
|
var inferFormatFromContentType = (contentType) => {
|
|
15253
15253
|
const normalizedType = (contentType || "").toLowerCase();
|
|
15254
|
+
if (normalizedType.includes("html")) {
|
|
15255
|
+
return "html";
|
|
15256
|
+
}
|
|
15254
15257
|
if (normalizedType.includes("xml")) {
|
|
15255
15258
|
return "xml";
|
|
15256
15259
|
}
|
|
@@ -19963,7 +19966,7 @@ var loadRAGDocumentFromURL = async (input) => {
|
|
|
19963
19966
|
contentType: input.contentType ?? response.headers.get("content-type") ?? undefined,
|
|
19964
19967
|
data,
|
|
19965
19968
|
extractorRegistry: input.extractorRegistry,
|
|
19966
|
-
format: input.format ?? inferFormatFromUrl(url),
|
|
19969
|
+
format: input.format ?? inferFormatFromContentType(input.contentType ?? response.headers.get("content-type")) ?? inferFormatFromUrl(url),
|
|
19967
19970
|
metadata: input.metadata,
|
|
19968
19971
|
name: basename(new URL(url).pathname),
|
|
19969
19972
|
source: input.source ?? url,
|
|
@@ -20011,7 +20014,7 @@ var loadRAGDocumentsFromURLs = async (input) => {
|
|
|
20011
20014
|
contentType: urlInput.contentType ?? response.headers.get("content-type") ?? undefined,
|
|
20012
20015
|
data,
|
|
20013
20016
|
extractorRegistry: urlInput.extractorRegistry ?? input.extractorRegistry,
|
|
20014
|
-
format: urlInput.format ?? inferFormatFromUrl(url),
|
|
20017
|
+
format: urlInput.format ?? inferFormatFromContentType(urlInput.contentType ?? response.headers.get("content-type")) ?? inferFormatFromUrl(url),
|
|
20015
20018
|
metadata: urlInput.metadata,
|
|
20016
20019
|
name: basename(new URL(url).pathname),
|
|
20017
20020
|
source: urlInput.source ?? url,
|
|
@@ -36572,6 +36575,56 @@ var createRAGOriginalTextTools = (options) => {
|
|
|
36572
36575
|
}
|
|
36573
36576
|
};
|
|
36574
36577
|
};
|
|
36578
|
+
// src/retrieval/quoteReferences.ts
|
|
36579
|
+
var createRAGQuoteReferences = () => {
|
|
36580
|
+
const quotes = new Map;
|
|
36581
|
+
const references = new Map;
|
|
36582
|
+
const record2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
36583
|
+
const encodePassage = (passage) => {
|
|
36584
|
+
if (!record2(passage) || typeof passage.text !== "string")
|
|
36585
|
+
return passage;
|
|
36586
|
+
const { text, ...metadata } = passage;
|
|
36587
|
+
const sentences = text.split(/(?<=[.!?])\s+(?=[A-Z])|\n+/u).filter((sentence) => sentence.trim());
|
|
36588
|
+
return {
|
|
36589
|
+
...metadata,
|
|
36590
|
+
sentences: sentences.map((sentence) => {
|
|
36591
|
+
let citation = references.get(sentence);
|
|
36592
|
+
if (!citation) {
|
|
36593
|
+
citation = `e${quotes.size + 1}`;
|
|
36594
|
+
references.set(sentence, citation);
|
|
36595
|
+
quotes.set(citation, sentence);
|
|
36596
|
+
}
|
|
36597
|
+
return { citation, text: sentence };
|
|
36598
|
+
})
|
|
36599
|
+
};
|
|
36600
|
+
};
|
|
36601
|
+
return {
|
|
36602
|
+
encodeToolResult: (serialized) => {
|
|
36603
|
+
let value;
|
|
36604
|
+
try {
|
|
36605
|
+
value = JSON.parse(serialized);
|
|
36606
|
+
} catch {
|
|
36607
|
+
return serialized;
|
|
36608
|
+
}
|
|
36609
|
+
if (!record2(value) || value.referenceOnly !== true)
|
|
36610
|
+
return serialized;
|
|
36611
|
+
if (Array.isArray(value.passages))
|
|
36612
|
+
return JSON.stringify({
|
|
36613
|
+
...value,
|
|
36614
|
+
passages: value.passages.map(encodePassage)
|
|
36615
|
+
});
|
|
36616
|
+
if (typeof value.text === "string")
|
|
36617
|
+
return JSON.stringify(encodePassage(value));
|
|
36618
|
+
return serialized;
|
|
36619
|
+
},
|
|
36620
|
+
resolve: (reference) => {
|
|
36621
|
+
const quote = quotes.get(reference);
|
|
36622
|
+
if (quote === undefined)
|
|
36623
|
+
throw new Error("Unknown retrieved quote reference");
|
|
36624
|
+
return quote;
|
|
36625
|
+
}
|
|
36626
|
+
};
|
|
36627
|
+
};
|
|
36575
36628
|
export {
|
|
36576
36629
|
addRAGEvaluationSuiteCase,
|
|
36577
36630
|
addRAGEvaluationSuiteCaseHardNegative,
|
|
@@ -36732,6 +36785,7 @@ export {
|
|
|
36732
36785
|
createRAGPresentationCueBenchmarkSnapshot,
|
|
36733
36786
|
createRAGPresentationCueBenchmarkSuite,
|
|
36734
36787
|
createRAGQueryTransform,
|
|
36788
|
+
createRAGQuoteReferences,
|
|
36735
36789
|
createRAGReranker,
|
|
36736
36790
|
createRAGSQLiteAnswerGroundingEvaluationHistoryStore,
|
|
36737
36791
|
createRAGSQLiteEvaluationHistoryStore,
|
|
@@ -36878,5 +36932,5 @@ export {
|
|
|
36878
36932
|
xaiEmbeddings
|
|
36879
36933
|
};
|
|
36880
36934
|
|
|
36881
|
-
//# debugId=
|
|
36935
|
+
//# debugId=3E13A042CB51A53E64756E2164756E21
|
|
36882
36936
|
//# sourceMappingURL=index.js.map
|