@absolutejs/rag 0.0.17 → 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 +98 -14
- 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 +21 -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/angular/index.js
CHANGED
|
@@ -2989,6 +2989,78 @@ var createRAGClient = (options) => {
|
|
|
2989
2989
|
}
|
|
2990
2990
|
return parseJson(response);
|
|
2991
2991
|
},
|
|
2992
|
+
async evaluateStream(input, options2) {
|
|
2993
|
+
const response = await fetchImpl(`${basePath}/evaluate/stream`, {
|
|
2994
|
+
body: JSON.stringify(input),
|
|
2995
|
+
headers: jsonHeaders,
|
|
2996
|
+
method: "POST",
|
|
2997
|
+
signal: options2?.signal
|
|
2998
|
+
});
|
|
2999
|
+
if (!response.ok || !response.body) {
|
|
3000
|
+
throw new Error(await toErrorMessage(response));
|
|
3001
|
+
}
|
|
3002
|
+
const reader = response.body.getReader();
|
|
3003
|
+
const decoder = new TextDecoder;
|
|
3004
|
+
let buffer = "";
|
|
3005
|
+
let result = null;
|
|
3006
|
+
let streamError = null;
|
|
3007
|
+
const handleEvent = (rawEvent) => {
|
|
3008
|
+
let eventName = "message";
|
|
3009
|
+
const dataLines = [];
|
|
3010
|
+
for (const line of rawEvent.split(`
|
|
3011
|
+
`)) {
|
|
3012
|
+
if (line.startsWith("event:")) {
|
|
3013
|
+
eventName = line.slice("event:".length).trim();
|
|
3014
|
+
} else if (line.startsWith("data:")) {
|
|
3015
|
+
dataLines.push(line.slice("data:".length).trim());
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
if (dataLines.length === 0) {
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
const payload = JSON.parse(dataLines.join(`
|
|
3022
|
+
`));
|
|
3023
|
+
if (eventName === "start") {
|
|
3024
|
+
options2?.onStart?.(payload);
|
|
3025
|
+
} else if (eventName === "case") {
|
|
3026
|
+
options2?.onCase?.(payload);
|
|
3027
|
+
} else if (eventName === "result") {
|
|
3028
|
+
result = payload;
|
|
3029
|
+
} else if (eventName === "error") {
|
|
3030
|
+
streamError = payload.error ?? "RAG evaluation stream failed";
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
for (;; ) {
|
|
3034
|
+
const { done, value } = await reader.read();
|
|
3035
|
+
if (done) {
|
|
3036
|
+
break;
|
|
3037
|
+
}
|
|
3038
|
+
buffer += decoder.decode(value, { stream: true });
|
|
3039
|
+
let separator = buffer.indexOf(`
|
|
3040
|
+
|
|
3041
|
+
`);
|
|
3042
|
+
while (separator !== -1) {
|
|
3043
|
+
const rawEvent = buffer.slice(0, separator);
|
|
3044
|
+
buffer = buffer.slice(separator + 2);
|
|
3045
|
+
if (rawEvent.trim().length > 0) {
|
|
3046
|
+
handleEvent(rawEvent);
|
|
3047
|
+
}
|
|
3048
|
+
separator = buffer.indexOf(`
|
|
3049
|
+
|
|
3050
|
+
`);
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
if (buffer.trim().length > 0) {
|
|
3054
|
+
handleEvent(buffer);
|
|
3055
|
+
}
|
|
3056
|
+
if (streamError) {
|
|
3057
|
+
throw new Error(streamError);
|
|
3058
|
+
}
|
|
3059
|
+
if (!result) {
|
|
3060
|
+
throw new Error("RAG evaluation stream ended without a result");
|
|
3061
|
+
}
|
|
3062
|
+
return result;
|
|
3063
|
+
},
|
|
2992
3064
|
async compareRetrievals(input) {
|
|
2993
3065
|
const response = await fetchImpl(`${basePath}/compare/retrieval`, {
|
|
2994
3066
|
body: JSON.stringify(input),
|
|
@@ -4382,5 +4454,5 @@ export {
|
|
|
4382
4454
|
RAGClientService
|
|
4383
4455
|
};
|
|
4384
4456
|
|
|
4385
|
-
//# debugId=
|
|
4457
|
+
//# debugId=951D20483FAD9D9B64756E2164756E21
|
|
4386
4458
|
//# sourceMappingURL=index.js.map
|