@absolutejs/rag 0.0.16 → 0.0.18
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/angular/index.js +73 -1
- package/dist/angular/index.js.map +4 -4
- package/dist/client/index.js +91 -14
- package/dist/client/index.js.map +4 -4
- package/dist/client/ui.js +19 -14
- package/dist/client/ui.js.map +3 -3
- package/dist/index.js +374 -14
- package/dist/index.js.map +7 -6
- package/dist/presentation/ui.js +316 -15
- package/dist/presentation/ui.js.map +6 -5
- package/dist/quality/quality.js +19 -14
- package/dist/quality/quality.js.map +3 -3
- package/dist/react/index.js +103 -1
- package/dist/react/index.js.map +5 -5
- package/dist/src/chat/chat.d.ts +21 -2
- package/dist/src/client/ragClient.d.ts +12 -1
- package/dist/src/presentation/htmxCitationFragments.d.ts +76 -0
- package/dist/src/presentation/htmxRenderers.d.ts +5 -1
- package/dist/src/presentation/ui.d.ts +2 -0
- package/dist/src/quality/quality.d.ts +6 -1
- package/dist/src/react/useRAG.d.ts +12 -0
- package/dist/src/react/useRAGEvaluate.d.ts +13 -1
- package/dist/svelte/index.js +73 -1
- package/dist/svelte/index.js.map +4 -4
- package/dist/vue/index.js +73 -1
- package/dist/vue/index.js.map +4 -4
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -5666,7 +5666,8 @@ var evaluateRAGCollectionCases = async ({
|
|
|
5666
5666
|
input,
|
|
5667
5667
|
defaultTopK = DEFAULT_TOP_K,
|
|
5668
5668
|
rerank,
|
|
5669
|
-
includeTrace = false
|
|
5669
|
+
includeTrace = false,
|
|
5670
|
+
onCaseSettled
|
|
5670
5671
|
}) => {
|
|
5671
5672
|
if (input.dryRun) {
|
|
5672
5673
|
return executeDryRunRAGEvaluation(input, defaultTopK).map((caseResult, caseIndex) => ({
|
|
@@ -5702,18 +5703,20 @@ var evaluateRAGCollectionCases = async ({
|
|
|
5702
5703
|
const sources = buildSources(searchOutcome.results);
|
|
5703
5704
|
const elapsedMs = Date.now() - startedAt;
|
|
5704
5705
|
const retrievedIds = normalizeExpectedIds(sources.map((source) => extractExpectedId(source, mode)));
|
|
5706
|
+
const caseResult = summarizeRAGEvaluationCase({
|
|
5707
|
+
caseIndex,
|
|
5708
|
+
caseInput: { ...caseInput, topK },
|
|
5709
|
+
elapsedMs,
|
|
5710
|
+
expectedIds,
|
|
5711
|
+
mode,
|
|
5712
|
+
query,
|
|
5713
|
+
retrievedIds,
|
|
5714
|
+
retrievedSources: sources,
|
|
5715
|
+
trace: searchOutcome.trace
|
|
5716
|
+
});
|
|
5717
|
+
onCaseSettled?.({ caseIndex, caseResult, total: input.cases.length });
|
|
5705
5718
|
return {
|
|
5706
|
-
caseResult
|
|
5707
|
-
caseIndex,
|
|
5708
|
-
caseInput: { ...caseInput, topK },
|
|
5709
|
-
elapsedMs,
|
|
5710
|
-
expectedIds,
|
|
5711
|
-
mode,
|
|
5712
|
-
query,
|
|
5713
|
-
retrievedIds,
|
|
5714
|
-
retrievedSources: sources,
|
|
5715
|
-
trace: searchOutcome.trace
|
|
5716
|
-
}),
|
|
5719
|
+
caseResult,
|
|
5717
5720
|
trace: searchOutcome.trace,
|
|
5718
5721
|
filter: searchInput.filter,
|
|
5719
5722
|
retrieval: searchInput.retrieval,
|
|
@@ -11077,13 +11080,15 @@ var evaluateRAGCollection = async ({
|
|
|
11077
11080
|
collection,
|
|
11078
11081
|
input,
|
|
11079
11082
|
defaultTopK = DEFAULT_TOP_K,
|
|
11080
|
-
rerank
|
|
11083
|
+
rerank,
|
|
11084
|
+
onCaseSettled
|
|
11081
11085
|
}) => {
|
|
11082
11086
|
const evaluated = await evaluateRAGCollectionCases({
|
|
11083
11087
|
collection,
|
|
11084
11088
|
defaultTopK,
|
|
11085
11089
|
includeTrace: false,
|
|
11086
11090
|
input,
|
|
11091
|
+
onCaseSettled,
|
|
11087
11092
|
rerank
|
|
11088
11093
|
});
|
|
11089
11094
|
return buildRAGEvaluationResponse(evaluated.map((entry) => entry.caseResult));
|
|
@@ -11466,6 +11471,78 @@ var createRAGClient = (options) => {
|
|
|
11466
11471
|
}
|
|
11467
11472
|
return parseJson(response);
|
|
11468
11473
|
},
|
|
11474
|
+
async evaluateStream(input, options2) {
|
|
11475
|
+
const response = await fetchImpl(`${basePath}/evaluate/stream`, {
|
|
11476
|
+
body: JSON.stringify(input),
|
|
11477
|
+
headers: jsonHeaders,
|
|
11478
|
+
method: "POST",
|
|
11479
|
+
signal: options2?.signal
|
|
11480
|
+
});
|
|
11481
|
+
if (!response.ok || !response.body) {
|
|
11482
|
+
throw new Error(await toErrorMessage(response));
|
|
11483
|
+
}
|
|
11484
|
+
const reader = response.body.getReader();
|
|
11485
|
+
const decoder = new TextDecoder;
|
|
11486
|
+
let buffer = "";
|
|
11487
|
+
let result = null;
|
|
11488
|
+
let streamError = null;
|
|
11489
|
+
const handleEvent = (rawEvent) => {
|
|
11490
|
+
let eventName = "message";
|
|
11491
|
+
const dataLines = [];
|
|
11492
|
+
for (const line of rawEvent.split(`
|
|
11493
|
+
`)) {
|
|
11494
|
+
if (line.startsWith("event:")) {
|
|
11495
|
+
eventName = line.slice("event:".length).trim();
|
|
11496
|
+
} else if (line.startsWith("data:")) {
|
|
11497
|
+
dataLines.push(line.slice("data:".length).trim());
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
if (dataLines.length === 0) {
|
|
11501
|
+
return;
|
|
11502
|
+
}
|
|
11503
|
+
const payload = JSON.parse(dataLines.join(`
|
|
11504
|
+
`));
|
|
11505
|
+
if (eventName === "start") {
|
|
11506
|
+
options2?.onStart?.(payload);
|
|
11507
|
+
} else if (eventName === "case") {
|
|
11508
|
+
options2?.onCase?.(payload);
|
|
11509
|
+
} else if (eventName === "result") {
|
|
11510
|
+
result = payload;
|
|
11511
|
+
} else if (eventName === "error") {
|
|
11512
|
+
streamError = payload.error ?? "RAG evaluation stream failed";
|
|
11513
|
+
}
|
|
11514
|
+
};
|
|
11515
|
+
for (;; ) {
|
|
11516
|
+
const { done, value } = await reader.read();
|
|
11517
|
+
if (done) {
|
|
11518
|
+
break;
|
|
11519
|
+
}
|
|
11520
|
+
buffer += decoder.decode(value, { stream: true });
|
|
11521
|
+
let separator = buffer.indexOf(`
|
|
11522
|
+
|
|
11523
|
+
`);
|
|
11524
|
+
while (separator !== -1) {
|
|
11525
|
+
const rawEvent = buffer.slice(0, separator);
|
|
11526
|
+
buffer = buffer.slice(separator + 2);
|
|
11527
|
+
if (rawEvent.trim().length > 0) {
|
|
11528
|
+
handleEvent(rawEvent);
|
|
11529
|
+
}
|
|
11530
|
+
separator = buffer.indexOf(`
|
|
11531
|
+
|
|
11532
|
+
`);
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
if (buffer.trim().length > 0) {
|
|
11536
|
+
handleEvent(buffer);
|
|
11537
|
+
}
|
|
11538
|
+
if (streamError) {
|
|
11539
|
+
throw new Error(streamError);
|
|
11540
|
+
}
|
|
11541
|
+
if (!result) {
|
|
11542
|
+
throw new Error("RAG evaluation stream ended without a result");
|
|
11543
|
+
}
|
|
11544
|
+
return result;
|
|
11545
|
+
},
|
|
11469
11546
|
async compareRetrievals(input) {
|
|
11470
11547
|
const response = await fetchImpl(`${basePath}/compare/retrieval`, {
|
|
11471
11548
|
body: JSON.stringify(input),
|
|
@@ -12624,5 +12701,5 @@ export {
|
|
|
12624
12701
|
buildRAGEvaluationLeaderboard
|
|
12625
12702
|
};
|
|
12626
12703
|
|
|
12627
|
-
//# debugId=
|
|
12704
|
+
//# debugId=53C15FFD52386C7864756E2164756E21
|
|
12628
12705
|
//# sourceMappingURL=index.js.map
|