@absolutejs/rag 0.0.17 → 0.0.19
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 +99 -15
- package/dist/index.js.map +4 -4
- package/dist/presentation/ui.js +19 -14
- package/dist/presentation/ui.js.map +3 -3
- 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 +30 -2
- package/dist/src/client/ragClient.d.ts +12 -1
- 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/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));
|
|
@@ -11653,7 +11658,7 @@ var resolveRAGHTMXRenderers = (custom = {}) => {
|
|
|
11653
11658
|
};
|
|
11654
11659
|
};
|
|
11655
11660
|
// src/chat/chat.ts
|
|
11656
|
-
import { Elysia } from "elysia";
|
|
11661
|
+
import { Elysia, sse } from "elysia";
|
|
11657
11662
|
|
|
11658
11663
|
// src/internal/constants.ts
|
|
11659
11664
|
var HTTP_STATUS_OK = 200;
|
|
@@ -30848,6 +30853,85 @@ var ragChat = (config) => {
|
|
|
30848
30853
|
}), HTTP_STATUS_OK);
|
|
30849
30854
|
}
|
|
30850
30855
|
return result;
|
|
30856
|
+
}).post(`${path}/evaluate/stream`, async function* ({ body, request }) {
|
|
30857
|
+
const input = toRAGEvaluationInput(body);
|
|
30858
|
+
if (!input) {
|
|
30859
|
+
yield sse({
|
|
30860
|
+
data: JSON.stringify({
|
|
30861
|
+
error: "Expected payload shape: { cases: [{ id, query, expectedChunkIds|expectedSources|expectedDocumentIds }] }"
|
|
30862
|
+
}),
|
|
30863
|
+
event: "error"
|
|
30864
|
+
});
|
|
30865
|
+
return;
|
|
30866
|
+
}
|
|
30867
|
+
const accessScope = await loadAccessScope(request);
|
|
30868
|
+
for (const evaluationCase of input.cases) {
|
|
30869
|
+
if (evaluationCase.corpusKey && !matchesAccessScope(accessScope, {
|
|
30870
|
+
corpusKey: evaluationCase.corpusKey
|
|
30871
|
+
}) || (evaluationCase.expectedDocumentIds ?? []).some((documentId) => !matchesAccessScope(accessScope, { documentId })) || (evaluationCase.expectedSources ?? []).some((source) => !matchesAccessScope(accessScope, { source }))) {
|
|
30872
|
+
yield sse({
|
|
30873
|
+
data: JSON.stringify({
|
|
30874
|
+
error: "Evaluation case is outside the allowed RAG access scope"
|
|
30875
|
+
}),
|
|
30876
|
+
event: "error"
|
|
30877
|
+
});
|
|
30878
|
+
return;
|
|
30879
|
+
}
|
|
30880
|
+
}
|
|
30881
|
+
const collection = resolveCollection();
|
|
30882
|
+
if (!collection) {
|
|
30883
|
+
yield sse({
|
|
30884
|
+
data: JSON.stringify({ error: "RAG collection is not configured" }),
|
|
30885
|
+
event: "error"
|
|
30886
|
+
});
|
|
30887
|
+
return;
|
|
30888
|
+
}
|
|
30889
|
+
yield sse({
|
|
30890
|
+
data: JSON.stringify({ total: input.cases.length }),
|
|
30891
|
+
event: "start"
|
|
30892
|
+
});
|
|
30893
|
+
const pending = [];
|
|
30894
|
+
let resolveNext = null;
|
|
30895
|
+
let finished = false;
|
|
30896
|
+
const wake = () => {
|
|
30897
|
+
const resolve2 = resolveNext;
|
|
30898
|
+
resolveNext = null;
|
|
30899
|
+
resolve2?.();
|
|
30900
|
+
};
|
|
30901
|
+
const resultPromise = evaluateRAGCollection({
|
|
30902
|
+
collection,
|
|
30903
|
+
defaultTopK: topK,
|
|
30904
|
+
input,
|
|
30905
|
+
onCaseSettled: (event) => {
|
|
30906
|
+
pending.push(event);
|
|
30907
|
+
wake();
|
|
30908
|
+
}
|
|
30909
|
+
}).finally(() => {
|
|
30910
|
+
finished = true;
|
|
30911
|
+
wake();
|
|
30912
|
+
});
|
|
30913
|
+
while (true) {
|
|
30914
|
+
while (pending.length > 0) {
|
|
30915
|
+
yield sse({ data: JSON.stringify(pending.shift()), event: "case" });
|
|
30916
|
+
}
|
|
30917
|
+
if (finished) {
|
|
30918
|
+
break;
|
|
30919
|
+
}
|
|
30920
|
+
await new Promise((resolve2) => {
|
|
30921
|
+
resolveNext = resolve2;
|
|
30922
|
+
});
|
|
30923
|
+
}
|
|
30924
|
+
try {
|
|
30925
|
+
const result = await resultPromise;
|
|
30926
|
+
yield sse({ data: JSON.stringify(result), event: "result" });
|
|
30927
|
+
} catch (caught) {
|
|
30928
|
+
yield sse({
|
|
30929
|
+
data: JSON.stringify({
|
|
30930
|
+
error: caught instanceof Error ? caught.message : String(caught)
|
|
30931
|
+
}),
|
|
30932
|
+
event: "error"
|
|
30933
|
+
});
|
|
30934
|
+
}
|
|
30851
30935
|
}).get(`${path}/status`, async ({ request }) => {
|
|
30852
30936
|
const result = await handleStatus(request);
|
|
30853
30937
|
if (config.htmx && isHTMXRequest(request)) {
|
|
@@ -38080,5 +38164,5 @@ export {
|
|
|
38080
38164
|
addRAGEvaluationSuiteCase
|
|
38081
38165
|
};
|
|
38082
38166
|
|
|
38083
|
-
//# debugId=
|
|
38167
|
+
//# debugId=BD3325EB562F864664756E2164756E21
|
|
38084
38168
|
//# sourceMappingURL=index.js.map
|