@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/vue/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),
|
|
@@ -4904,5 +4976,5 @@ export {
|
|
|
4904
4976
|
useRAG
|
|
4905
4977
|
};
|
|
4906
4978
|
|
|
4907
|
-
//# debugId=
|
|
4979
|
+
//# debugId=AEB60E9CDC7E85E464756E2164756E21
|
|
4908
4980
|
//# sourceMappingURL=index.js.map
|