@absolutejs/rag 0.0.7 → 0.0.8
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/ai/rag/index.js +21 -9
- package/dist/ai/rag/index.js.map +3 -3
- package/package.json +131 -131
package/dist/ai/rag/index.js
CHANGED
|
@@ -21676,6 +21676,7 @@ var MAX_INGEST_JOBS = 20;
|
|
|
21676
21676
|
var MAX_ADMIN_ACTIONS = 20;
|
|
21677
21677
|
var MAX_ADMIN_JOBS = 20;
|
|
21678
21678
|
var DEFAULT_STALE_AFTER_MS = 1000 * 60 * 60 * 24 * 7;
|
|
21679
|
+
var REQUEST_USER_SUB_HEADER = "x-absolutejs-user-sub";
|
|
21679
21680
|
var HTML_HEADERS = { "Content-Type": "text/html; charset=utf-8" };
|
|
21680
21681
|
var defaultParseProvider = (content) => {
|
|
21681
21682
|
const colonIdx = content.indexOf(":");
|
|
@@ -21689,6 +21690,10 @@ var defaultParseProvider = (content) => {
|
|
|
21689
21690
|
var normalizeScore = (value) => Number.isFinite(value) ? value : 0;
|
|
21690
21691
|
var isHTMXRequest = (request) => request.headers.get("HX-Request") === "true";
|
|
21691
21692
|
var isObjectRecord3 = (value) => Boolean(value) && typeof value === "object";
|
|
21693
|
+
var resolveRequestUserSub = (request) => {
|
|
21694
|
+
const value = request?.headers.get(REQUEST_USER_SUB_HEADER)?.trim();
|
|
21695
|
+
return value ? value : undefined;
|
|
21696
|
+
};
|
|
21692
21697
|
var getStringProperty = (value, key) => {
|
|
21693
21698
|
if (!isObjectRecord3(value)) {
|
|
21694
21699
|
return;
|
|
@@ -22528,11 +22533,12 @@ var ragChat = (config) => {
|
|
|
22528
22533
|
throw error;
|
|
22529
22534
|
}
|
|
22530
22535
|
};
|
|
22531
|
-
const buildSyncSources = async (scope) => {
|
|
22536
|
+
const buildSyncSources = async (scope, request) => {
|
|
22532
22537
|
if (!indexManager?.listSyncSources) {
|
|
22533
22538
|
return [];
|
|
22534
22539
|
}
|
|
22535
|
-
const
|
|
22540
|
+
const userSub = resolveRequestUserSub(request);
|
|
22541
|
+
const sources = await indexManager.listSyncSources(userSub ? { userSub } : undefined);
|
|
22536
22542
|
return sources.filter((source) => matchesSyncSourceScope(scope, source));
|
|
22537
22543
|
};
|
|
22538
22544
|
const toHTMXResponse = (html, status, extraHeaders) => new Response(html, {
|
|
@@ -28746,7 +28752,7 @@ var ragChat = (config) => {
|
|
|
28746
28752
|
stats: traceStats
|
|
28747
28753
|
},
|
|
28748
28754
|
status,
|
|
28749
|
-
syncSources: await buildSyncSources(accessScope)
|
|
28755
|
+
syncSources: await buildSyncSources(accessScope, request)
|
|
28750
28756
|
};
|
|
28751
28757
|
};
|
|
28752
28758
|
const handleStatus = async (request) => buildOperationsPayload(request);
|
|
@@ -29208,7 +29214,7 @@ var ragChat = (config) => {
|
|
|
29208
29214
|
const accessScope = await loadAccessScope(request);
|
|
29209
29215
|
return {
|
|
29210
29216
|
ok: true,
|
|
29211
|
-
sources: await buildSyncSources(accessScope)
|
|
29217
|
+
sources: await buildSyncSources(accessScope, request)
|
|
29212
29218
|
};
|
|
29213
29219
|
};
|
|
29214
29220
|
const handleSyncAllSources = async (request, options) => {
|
|
@@ -29228,7 +29234,10 @@ var ragChat = (config) => {
|
|
|
29228
29234
|
const job = createAdminJob("sync_all_sources", undefined, syncJobs);
|
|
29229
29235
|
const action = createAdminAction("sync_all_sources");
|
|
29230
29236
|
try {
|
|
29231
|
-
const result = await indexManager.syncAllSources(
|
|
29237
|
+
const result = await indexManager.syncAllSources({
|
|
29238
|
+
...options ?? {},
|
|
29239
|
+
userSub: resolveRequestUserSub(request)
|
|
29240
|
+
});
|
|
29232
29241
|
if (result && "ok" in result) {
|
|
29233
29242
|
if (!result.ok) {
|
|
29234
29243
|
failAdminJob(job, result.error);
|
|
@@ -29250,7 +29259,7 @@ var ragChat = (config) => {
|
|
|
29250
29259
|
completeAdminAction(action);
|
|
29251
29260
|
return {
|
|
29252
29261
|
ok: true,
|
|
29253
|
-
sources: await buildSyncSources(accessScope)
|
|
29262
|
+
sources: await buildSyncSources(accessScope, request)
|
|
29254
29263
|
};
|
|
29255
29264
|
} catch (caught) {
|
|
29256
29265
|
const message = caught instanceof Error ? caught.message : String(caught);
|
|
@@ -29282,7 +29291,10 @@ var ragChat = (config) => {
|
|
|
29282
29291
|
const job = createAdminJob("sync_source", id, syncJobs);
|
|
29283
29292
|
const action = createAdminAction("sync_source", undefined, id);
|
|
29284
29293
|
try {
|
|
29285
|
-
const result = await indexManager.syncSource(id,
|
|
29294
|
+
const result = await indexManager.syncSource(id, {
|
|
29295
|
+
...options ?? {},
|
|
29296
|
+
userSub: resolveRequestUserSub(request)
|
|
29297
|
+
});
|
|
29286
29298
|
if (result && "ok" in result) {
|
|
29287
29299
|
if (!result.ok) {
|
|
29288
29300
|
failAdminJob(job, result.error);
|
|
@@ -29295,7 +29307,7 @@ var ragChat = (config) => {
|
|
|
29295
29307
|
}
|
|
29296
29308
|
completeAdminJob(job);
|
|
29297
29309
|
completeAdminAction(action);
|
|
29298
|
-
const source = (await buildSyncSources(accessScope)).find((record) => record.id === id);
|
|
29310
|
+
const source = (await buildSyncSources(accessScope, request)).find((record) => record.id === id);
|
|
29299
29311
|
return source ? { ok: true, source } : {
|
|
29300
29312
|
error: "sync source not found",
|
|
29301
29313
|
ok: false
|
|
@@ -37462,5 +37474,5 @@ export {
|
|
|
37462
37474
|
addRAGEvaluationSuiteCase
|
|
37463
37475
|
};
|
|
37464
37476
|
|
|
37465
|
-
//# debugId=
|
|
37477
|
+
//# debugId=C60E619F8D901C1764756E2164756E21
|
|
37466
37478
|
//# sourceMappingURL=index.js.map
|