@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/src/chat/chat.d.ts
CHANGED
|
@@ -1014,6 +1014,25 @@ export declare const ragChat: (config: RAGChatPluginConfig) => Elysia<"", {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
};
|
|
1016
1016
|
};
|
|
1017
|
+
} & {
|
|
1018
|
+
[x: string]: {
|
|
1019
|
+
evaluate: {
|
|
1020
|
+
stream: {
|
|
1021
|
+
post: {
|
|
1022
|
+
body: unknown;
|
|
1023
|
+
params: {};
|
|
1024
|
+
query: unknown;
|
|
1025
|
+
headers: unknown;
|
|
1026
|
+
response: {
|
|
1027
|
+
200: AsyncGenerator<{
|
|
1028
|
+
data: string;
|
|
1029
|
+
event: string;
|
|
1030
|
+
}, void, unknown>;
|
|
1031
|
+
};
|
|
1032
|
+
};
|
|
1033
|
+
};
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1017
1036
|
} & {
|
|
1018
1037
|
[x: string]: {
|
|
1019
1038
|
status: {
|
|
@@ -1226,7 +1245,7 @@ export declare const ragChat: (config: RAGChatPluginConfig) => Elysia<"", {
|
|
|
1226
1245
|
};
|
|
1227
1246
|
};
|
|
1228
1247
|
};
|
|
1229
|
-
} & {
|
|
1248
|
+
} & ({
|
|
1230
1249
|
[x: string]: {
|
|
1231
1250
|
status: {
|
|
1232
1251
|
handoffs: {
|
|
@@ -1261,7 +1280,7 @@ export declare const ragChat: (config: RAGChatPluginConfig) => Elysia<"", {
|
|
|
1261
1280
|
};
|
|
1262
1281
|
};
|
|
1263
1282
|
};
|
|
1264
|
-
} &
|
|
1283
|
+
} & {
|
|
1265
1284
|
[x: string]: {
|
|
1266
1285
|
ops: {
|
|
1267
1286
|
get: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RAGBackendsResponse, RAGDocumentChunksResponse, RAGEvaluationInput, RAGEvaluationResponse, RAGRetrievalBaselinePromotionFromRunRequest, RAGRetrievalBaselinePromotionRequest, RAGRetrievalBaselineRevertRequest, RAGRetrievalReleaseIncidentAcknowledgeRequest, RAGRetrievalReleaseDecisionActionRequest, RAGRetrievalBaselineResponse, RAGRetrievalLaneHandoffDecisionRequest, RAGRetrievalLaneHandoffDecisionResponse, RAGRetrievalLaneHandoffIncidentStatusResponse, RAGRetrievalLaneHandoffStatusResponse, RAGRetrievalIncidentRemediationDecisionRequest, RAGRetrievalIncidentRemediationBulkExecutionRequest, RAGRetrievalIncidentRemediationExecutionRequest, RAGRetrievalIncidentRemediationExecutionResponse, RAGRetrievalIncidentRemediationStatusResponse, RAGRetrievalReleaseGroupHistoryResponse, RAGRetrievalReleaseIncidentStatusResponse, RAGRetrievalReleaseDriftStatusResponse, RAGRetrievalComparisonRequest, RAGAdaptiveNativePlannerBenchmarkResponse, RAGAdaptiveNativePlannerBenchmarkSnapshotResponse, RAGDocumentIngestInput, RAGDocumentChunk, RAGDocumentsResponse, RAGDocumentUrlIngestInput, RAGDocumentUploadIngestInput, RAGIngestResponse, RAGMutationResponse, RAGOperationsResponse, RAGSearchRequest, RAGSearchTracePruneResponse, RAGSource, RAGStatusResponse, RAGSyncRunOptions, RAGSyncResponse } from "@absolutejs/ai";
|
|
1
|
+
import type { RAGBackendsResponse, RAGDocumentChunksResponse, RAGEvaluationCaseResult, RAGEvaluationInput, RAGEvaluationResponse, RAGRetrievalBaselinePromotionFromRunRequest, RAGRetrievalBaselinePromotionRequest, RAGRetrievalBaselineRevertRequest, RAGRetrievalReleaseIncidentAcknowledgeRequest, RAGRetrievalReleaseDecisionActionRequest, RAGRetrievalBaselineResponse, RAGRetrievalLaneHandoffDecisionRequest, RAGRetrievalLaneHandoffDecisionResponse, RAGRetrievalLaneHandoffIncidentStatusResponse, RAGRetrievalLaneHandoffStatusResponse, RAGRetrievalIncidentRemediationDecisionRequest, RAGRetrievalIncidentRemediationBulkExecutionRequest, RAGRetrievalIncidentRemediationExecutionRequest, RAGRetrievalIncidentRemediationExecutionResponse, RAGRetrievalIncidentRemediationStatusResponse, RAGRetrievalReleaseGroupHistoryResponse, RAGRetrievalReleaseIncidentStatusResponse, RAGRetrievalReleaseDriftStatusResponse, RAGRetrievalComparisonRequest, RAGAdaptiveNativePlannerBenchmarkResponse, RAGAdaptiveNativePlannerBenchmarkSnapshotResponse, RAGDocumentIngestInput, RAGDocumentChunk, RAGDocumentsResponse, RAGDocumentUrlIngestInput, RAGDocumentUploadIngestInput, RAGIngestResponse, RAGMutationResponse, RAGOperationsResponse, RAGSearchRequest, RAGSearchTracePruneResponse, RAGSource, RAGStatusResponse, RAGSyncRunOptions, RAGSyncResponse } from "@absolutejs/ai";
|
|
2
2
|
import type { RAGClientOptions, RAGDetailedSearchResponse, RAGMaintenanceOverview, RAGMaintenancePayload } from "../../types/client";
|
|
3
3
|
export declare const buildRAGMaintenanceOverview: (payload: RAGMaintenancePayload) => RAGMaintenanceOverview;
|
|
4
4
|
export declare const createRAGClient: (options: RAGClientOptions) => {
|
|
@@ -11,6 +11,17 @@ export declare const createRAGClient: (options: RAGClientOptions) => {
|
|
|
11
11
|
documentChunks(id: string): Promise<RAGDocumentChunksResponse>;
|
|
12
12
|
documents(kind?: string): Promise<RAGDocumentsResponse>;
|
|
13
13
|
evaluate(input: RAGEvaluationInput): Promise<RAGEvaluationResponse>;
|
|
14
|
+
evaluateStream(input: RAGEvaluationInput, options?: {
|
|
15
|
+
onStart?: (event: {
|
|
16
|
+
total: number;
|
|
17
|
+
}) => void;
|
|
18
|
+
onCase?: (event: {
|
|
19
|
+
caseIndex: number;
|
|
20
|
+
total: number;
|
|
21
|
+
caseResult: RAGEvaluationCaseResult;
|
|
22
|
+
}) => void;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}): Promise<RAGEvaluationResponse>;
|
|
14
25
|
compareRetrievals(input: RAGRetrievalComparisonRequest): Promise<import("@absolutejs/ai").RAGRetrievalComparison>;
|
|
15
26
|
retrievalComparisonHistory(input?: {
|
|
16
27
|
limit?: number;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { RAGCitation, RAGGroundingReference, RAGSectionRetrievalDiagnostic, RAGSourceSummary } from "@absolutejs/ai";
|
|
2
|
+
export type RAGSectionDiagnostic = RAGSectionRetrievalDiagnostic & {
|
|
3
|
+
peakStage?: string;
|
|
4
|
+
peakCount?: number;
|
|
5
|
+
finalCount?: number;
|
|
6
|
+
finalRetentionRate?: number;
|
|
7
|
+
dropFromPeak?: number;
|
|
8
|
+
queryAttribution?: {
|
|
9
|
+
mode: "primary" | "transformed" | "variant" | "mixed";
|
|
10
|
+
primaryHits: number;
|
|
11
|
+
transformedHits: number;
|
|
12
|
+
variantHits: number;
|
|
13
|
+
reasons: string[];
|
|
14
|
+
};
|
|
15
|
+
stageWeights?: Array<{
|
|
16
|
+
stage: string;
|
|
17
|
+
count: number;
|
|
18
|
+
previousStage?: string;
|
|
19
|
+
previousCount?: number;
|
|
20
|
+
countDelta?: number;
|
|
21
|
+
retentionRate?: number;
|
|
22
|
+
totalScore?: number;
|
|
23
|
+
stageScoreShare?: number;
|
|
24
|
+
parentStageScoreShare?: number;
|
|
25
|
+
stageScoreShareGap?: number;
|
|
26
|
+
parentStageScoreShareGap?: number;
|
|
27
|
+
stageShare: number;
|
|
28
|
+
parentStageShare?: number;
|
|
29
|
+
stageShareGap?: number;
|
|
30
|
+
parentStageShareGap?: number;
|
|
31
|
+
strongestSiblingLabel?: string;
|
|
32
|
+
strongestSiblingCount?: number;
|
|
33
|
+
reasons: string[];
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
export type RAGSourceSummaryGroup = {
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
targetId: string;
|
|
40
|
+
summary: string;
|
|
41
|
+
summaries: RAGSourceSummary[];
|
|
42
|
+
};
|
|
43
|
+
export type RAGGroundingReferenceGroup = {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
targetId: string;
|
|
47
|
+
summary: string;
|
|
48
|
+
references: RAGGroundingReference[];
|
|
49
|
+
};
|
|
50
|
+
export type RAGCitationGroup = {
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
targetId: string;
|
|
54
|
+
summary: string;
|
|
55
|
+
citations: RAGCitation[];
|
|
56
|
+
};
|
|
57
|
+
export declare const buildSearchTargetId: (prefix: string, value: string) => string;
|
|
58
|
+
export declare const buildSourceSummarySectionGroups: (summaries?: RAGSourceSummary[] | null) => RAGSourceSummaryGroup[];
|
|
59
|
+
export declare const buildGroundingReferenceGroups: (references?: RAGGroundingReference[] | null) => RAGGroundingReferenceGroup[];
|
|
60
|
+
export declare const buildCitationGroups: (citations?: RAGCitation[] | null) => RAGCitationGroup[];
|
|
61
|
+
export declare const formatCitationLabel: (citation: RAGCitation) => string;
|
|
62
|
+
export declare const formatCitationSummary: (citation: RAGCitation) => string;
|
|
63
|
+
export declare const formatCitationExcerpt: (citation: RAGCitation) => string;
|
|
64
|
+
export declare const formatSourceSummaryDetails: (summary: RAGSourceSummary) => string[];
|
|
65
|
+
export declare const formatCitationDetails: (citation: RAGCitation) => string[];
|
|
66
|
+
export declare const formatSectionDiagnosticChannels: (diagnostic: RAGSectionRetrievalDiagnostic) => string;
|
|
67
|
+
export declare const formatSectionDiagnosticAttributionFocus: (diagnostic: RAGSectionDiagnostic) => string;
|
|
68
|
+
export declare const formatSectionDiagnosticPipeline: (diagnostic: RAGSectionDiagnostic) => string;
|
|
69
|
+
export declare const formatSectionDiagnosticStageFlow: (diagnostic: RAGSectionRetrievalDiagnostic) => string | null;
|
|
70
|
+
export declare const formatSectionDiagnosticStageBounds: (diagnostic: RAGSectionDiagnostic) => string | null;
|
|
71
|
+
export declare const formatSectionDiagnosticStageWeightRows: (diagnostic: RAGSectionDiagnostic) => string[];
|
|
72
|
+
export declare const formatSectionDiagnosticStageWeightReasons: (diagnostic: RAGSectionDiagnostic) => string[];
|
|
73
|
+
export declare const formatSectionDiagnosticCompetition: (diagnostic: RAGSectionRetrievalDiagnostic) => string;
|
|
74
|
+
export declare const formatSectionDiagnosticTopEntry: (diagnostic: RAGSectionDiagnostic) => string;
|
|
75
|
+
export declare const formatSectionDiagnosticReasons: (diagnostic: RAGSectionDiagnostic) => string[];
|
|
76
|
+
export declare const formatSectionDiagnosticDistributionRows: (diagnostic: RAGSectionRetrievalDiagnostic) => string[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { RAGAdminActionRecord, RAGAdminJobRecord, RAGBackendCapabilities, RAGVectorStoreStatus } from "@absolutejs/ai";
|
|
1
|
+
import type { RAGAdminActionRecord, RAGAdminJobRecord, RAGBackendCapabilities, RAGSource, RAGVectorStoreStatus } from "@absolutejs/ai";
|
|
2
|
+
import { type RAGSectionDiagnostic } from "./htmxCitationFragments";
|
|
2
3
|
import { buildRAGRetrievalTracePresentation } from "./presentation";
|
|
3
4
|
type RetrievalTrace = Parameters<typeof buildRAGRetrievalTracePresentation>[0];
|
|
4
5
|
declare const STREAM_STAGES: readonly ["submitting", "retrieving", "retrieved", "streaming", "complete"];
|
|
@@ -23,6 +24,9 @@ export type RAGHTMXRenderConfig = {
|
|
|
23
24
|
detailList?: (lines: string[], fallback: string) => string;
|
|
24
25
|
adminJobCards?: (jobs?: RAGAdminJobRecord[]) => string;
|
|
25
26
|
adminActionCards?: (actions?: RAGAdminActionRecord[]) => string;
|
|
27
|
+
citations?: (sources: RAGSource[]) => string;
|
|
28
|
+
sourceSummaries?: (sources: RAGSource[]) => string;
|
|
29
|
+
sectionDiagnosticCard?: (diagnostic: RAGSectionDiagnostic) => string;
|
|
26
30
|
};
|
|
27
31
|
export type ResolvedRAGHTMXRenderers = Required<Omit<RAGHTMXRenderConfig, "classPrefix">> & {
|
|
28
32
|
classPrefix: string;
|
|
@@ -4,3 +4,5 @@ export { buildRAGAnswerGroundingCaseSnapshotPresentations, buildRAGAnswerGroundi
|
|
|
4
4
|
export type { RAGStreamProgress, RAGStreamProgressState, } from "./workflowState";
|
|
5
5
|
export { resolveRAGHTMXRenderers } from "./htmxRenderers";
|
|
6
6
|
export type { RAGHTMXRenderConfig, ResolvedRAGHTMXRenderers, } from "./htmxRenderers";
|
|
7
|
+
export { buildCitationGroups, buildGroundingReferenceGroups, buildSearchTargetId, buildSourceSummarySectionGroups, formatCitationDetails, formatCitationExcerpt, formatCitationLabel, formatCitationSummary, formatSectionDiagnosticAttributionFocus, formatSectionDiagnosticChannels, formatSectionDiagnosticCompetition, formatSectionDiagnosticDistributionRows, formatSectionDiagnosticPipeline, formatSectionDiagnosticReasons, formatSectionDiagnosticStageBounds, formatSectionDiagnosticStageFlow, formatSectionDiagnosticStageWeightReasons, formatSectionDiagnosticStageWeightRows, formatSectionDiagnosticTopEntry, formatSourceSummaryDetails, } from "./htmxCitationFragments";
|
|
8
|
+
export type { RAGCitationGroup, RAGGroundingReferenceGroup, RAGSectionDiagnostic, RAGSourceSummaryGroup, } from "./htmxCitationFragments";
|
|
@@ -461,11 +461,16 @@ export declare const buildRAGEvaluationSuiteSnapshotDiff: ({ current, previous,
|
|
|
461
461
|
current: RAGEvaluationSuiteSnapshot;
|
|
462
462
|
previous?: RAGEvaluationSuiteSnapshot;
|
|
463
463
|
}) => RAGEvaluationSuiteSnapshotDiff;
|
|
464
|
-
export declare const evaluateRAGCollection: ({ collection, input, defaultTopK, rerank, }: {
|
|
464
|
+
export declare const evaluateRAGCollection: ({ collection, input, defaultTopK, rerank, onCaseSettled, }: {
|
|
465
465
|
collection: RAGCollection;
|
|
466
466
|
input: RAGEvaluationInput;
|
|
467
467
|
defaultTopK?: number;
|
|
468
468
|
rerank?: RAGRerankerProviderLike;
|
|
469
|
+
onCaseSettled?: (event: {
|
|
470
|
+
caseIndex: number;
|
|
471
|
+
total: number;
|
|
472
|
+
caseResult: RAGEvaluationCaseResult;
|
|
473
|
+
}) => void;
|
|
469
474
|
}) => Promise<RAGEvaluationResponse>;
|
|
470
475
|
export declare const executeDryRunRAGEvaluation: (input: RAGEvaluationInput, defaultTopK?: number) => RAGEvaluationCaseResult[];
|
|
471
476
|
export declare const runRAGEvaluationSuite: ({ suite, evaluate, overrides, artifacts, }: {
|
|
@@ -42,6 +42,14 @@ export declare const useRAG: (path: string, options?: UseRAGOptions) => {
|
|
|
42
42
|
clearRuns: () => void;
|
|
43
43
|
error: string | null;
|
|
44
44
|
evaluate: (input: import("@absolutejs/ai").RAGEvaluationInput) => Promise<import("@absolutejs/ai").RAGEvaluationResponse>;
|
|
45
|
+
evaluateStream: (input: import("@absolutejs/ai").RAGEvaluationInput, options?: {
|
|
46
|
+
onCase?: (event: {
|
|
47
|
+
caseIndex: number;
|
|
48
|
+
total: number;
|
|
49
|
+
caseResult: import("@absolutejs/ai").RAGEvaluationCaseResult;
|
|
50
|
+
}) => void;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}) => Promise<import("@absolutejs/ai").RAGEvaluationResponse>;
|
|
45
53
|
isEvaluating: boolean;
|
|
46
54
|
lastRequest: import("@absolutejs/ai").RAGEvaluationInput | null;
|
|
47
55
|
lastResponse: import("@absolutejs/ai").RAGEvaluationResponse | null;
|
|
@@ -61,6 +69,10 @@ export declare const useRAG: (path: string, options?: UseRAGOptions) => {
|
|
|
61
69
|
traceSummary: import("@absolutejs/ai").RAGRetrievalTraceComparisonSummary | undefined;
|
|
62
70
|
}>;
|
|
63
71
|
saveSuite: (suite: import("@absolutejs/ai").RAGEvaluationSuite) => import("@absolutejs/ai").RAGEvaluationSuite;
|
|
72
|
+
streamProgress: {
|
|
73
|
+
done: number;
|
|
74
|
+
total: number;
|
|
75
|
+
} | null;
|
|
64
76
|
suiteRuns: import("@absolutejs/ai").RAGEvaluationSuiteRun[];
|
|
65
77
|
suites: import("@absolutejs/ai").RAGEvaluationSuite[];
|
|
66
78
|
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import type { RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationSuite, RAGEvaluationSuiteRun } from "@absolutejs/ai";
|
|
1
|
+
import type { RAGEvaluationCaseResult, RAGEvaluationInput, RAGEvaluationResponse, RAGEvaluationSuite, RAGEvaluationSuiteRun } from "@absolutejs/ai";
|
|
2
2
|
export declare const useRAGEvaluate: (path: string) => {
|
|
3
3
|
clearRuns: () => void;
|
|
4
4
|
error: string | null;
|
|
5
5
|
evaluate: (input: RAGEvaluationInput) => Promise<RAGEvaluationResponse>;
|
|
6
|
+
evaluateStream: (input: RAGEvaluationInput, options?: {
|
|
7
|
+
onCase?: (event: {
|
|
8
|
+
caseIndex: number;
|
|
9
|
+
total: number;
|
|
10
|
+
caseResult: RAGEvaluationCaseResult;
|
|
11
|
+
}) => void;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}) => Promise<RAGEvaluationResponse>;
|
|
6
14
|
isEvaluating: boolean;
|
|
7
15
|
lastRequest: RAGEvaluationInput | null;
|
|
8
16
|
lastResponse: RAGEvaluationResponse | null;
|
|
@@ -22,6 +30,10 @@ export declare const useRAGEvaluate: (path: string) => {
|
|
|
22
30
|
traceSummary: import("@absolutejs/ai").RAGRetrievalTraceComparisonSummary | undefined;
|
|
23
31
|
}>;
|
|
24
32
|
saveSuite: (suite: RAGEvaluationSuite) => RAGEvaluationSuite;
|
|
33
|
+
streamProgress: {
|
|
34
|
+
done: number;
|
|
35
|
+
total: number;
|
|
36
|
+
} | null;
|
|
25
37
|
suiteRuns: RAGEvaluationSuiteRun[];
|
|
26
38
|
suites: RAGEvaluationSuite[];
|
|
27
39
|
};
|
package/dist/svelte/index.js
CHANGED
|
@@ -194,6 +194,78 @@ var createRAGClient = (options) => {
|
|
|
194
194
|
}
|
|
195
195
|
return parseJson(response);
|
|
196
196
|
},
|
|
197
|
+
async evaluateStream(input, options2) {
|
|
198
|
+
const response = await fetchImpl(`${basePath}/evaluate/stream`, {
|
|
199
|
+
body: JSON.stringify(input),
|
|
200
|
+
headers: jsonHeaders,
|
|
201
|
+
method: "POST",
|
|
202
|
+
signal: options2?.signal
|
|
203
|
+
});
|
|
204
|
+
if (!response.ok || !response.body) {
|
|
205
|
+
throw new Error(await toErrorMessage(response));
|
|
206
|
+
}
|
|
207
|
+
const reader = response.body.getReader();
|
|
208
|
+
const decoder = new TextDecoder;
|
|
209
|
+
let buffer = "";
|
|
210
|
+
let result = null;
|
|
211
|
+
let streamError = null;
|
|
212
|
+
const handleEvent = (rawEvent) => {
|
|
213
|
+
let eventName = "message";
|
|
214
|
+
const dataLines = [];
|
|
215
|
+
for (const line of rawEvent.split(`
|
|
216
|
+
`)) {
|
|
217
|
+
if (line.startsWith("event:")) {
|
|
218
|
+
eventName = line.slice("event:".length).trim();
|
|
219
|
+
} else if (line.startsWith("data:")) {
|
|
220
|
+
dataLines.push(line.slice("data:".length).trim());
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (dataLines.length === 0) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const payload = JSON.parse(dataLines.join(`
|
|
227
|
+
`));
|
|
228
|
+
if (eventName === "start") {
|
|
229
|
+
options2?.onStart?.(payload);
|
|
230
|
+
} else if (eventName === "case") {
|
|
231
|
+
options2?.onCase?.(payload);
|
|
232
|
+
} else if (eventName === "result") {
|
|
233
|
+
result = payload;
|
|
234
|
+
} else if (eventName === "error") {
|
|
235
|
+
streamError = payload.error ?? "RAG evaluation stream failed";
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
for (;; ) {
|
|
239
|
+
const { done, value } = await reader.read();
|
|
240
|
+
if (done) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
buffer += decoder.decode(value, { stream: true });
|
|
244
|
+
let separator = buffer.indexOf(`
|
|
245
|
+
|
|
246
|
+
`);
|
|
247
|
+
while (separator !== -1) {
|
|
248
|
+
const rawEvent = buffer.slice(0, separator);
|
|
249
|
+
buffer = buffer.slice(separator + 2);
|
|
250
|
+
if (rawEvent.trim().length > 0) {
|
|
251
|
+
handleEvent(rawEvent);
|
|
252
|
+
}
|
|
253
|
+
separator = buffer.indexOf(`
|
|
254
|
+
|
|
255
|
+
`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (buffer.trim().length > 0) {
|
|
259
|
+
handleEvent(buffer);
|
|
260
|
+
}
|
|
261
|
+
if (streamError) {
|
|
262
|
+
throw new Error(streamError);
|
|
263
|
+
}
|
|
264
|
+
if (!result) {
|
|
265
|
+
throw new Error("RAG evaluation stream ended without a result");
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
},
|
|
197
269
|
async compareRetrievals(input) {
|
|
198
270
|
const response = await fetchImpl(`${basePath}/compare/retrieval`, {
|
|
199
271
|
body: JSON.stringify(input),
|
|
@@ -4929,5 +5001,5 @@ export {
|
|
|
4929
5001
|
createRAG
|
|
4930
5002
|
};
|
|
4931
5003
|
|
|
4932
|
-
//# debugId=
|
|
5004
|
+
//# debugId=0C820FFEEA16A64064756E2164756E21
|
|
4933
5005
|
//# sourceMappingURL=index.js.map
|