@absolutejs/rag 0.0.15 → 0.0.16
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/index.js +195 -40
- package/dist/index.js.map +4 -3
- package/dist/presentation/ui.js +157 -1
- package/dist/presentation/ui.js.map +5 -4
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/src/presentation/htmxRenderers.d.ts +31 -0
- package/dist/src/presentation/ui.d.ts +2 -0
- package/dist/svelte/index.js +1 -1
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/index.js +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/presentation/ui.js
CHANGED
|
@@ -11221,8 +11221,164 @@ var summarizeRAGRetrievalComparison = (entries) => ({
|
|
|
11221
11221
|
bestByLowestRuntimeCandidateBudgetExhaustedCases: selectComparisonEntryByLowestTraceMetric(entries, "retrievalId", "runtimeCandidateBudgetExhaustedCases"),
|
|
11222
11222
|
bestByLowestRuntimeUnderfilledTopKCases: selectComparisonEntryByLowestTraceMetric(entries, "retrievalId", "runtimeUnderfilledTopKCases")
|
|
11223
11223
|
});
|
|
11224
|
+
// src/presentation/htmxRenderers.ts
|
|
11225
|
+
var STREAM_STAGES = [
|
|
11226
|
+
"submitting",
|
|
11227
|
+
"retrieving",
|
|
11228
|
+
"retrieved",
|
|
11229
|
+
"streaming",
|
|
11230
|
+
"complete"
|
|
11231
|
+
];
|
|
11232
|
+
var escapeHtml = (text) => text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
11233
|
+
var formatTime = (timestamp) => {
|
|
11234
|
+
if (!timestamp) {
|
|
11235
|
+
return "n/a";
|
|
11236
|
+
}
|
|
11237
|
+
return new Date(timestamp).toLocaleTimeString([], {
|
|
11238
|
+
hour: "numeric",
|
|
11239
|
+
minute: "2-digit",
|
|
11240
|
+
second: "2-digit"
|
|
11241
|
+
});
|
|
11242
|
+
};
|
|
11243
|
+
var formatDuration = (durationMs) => typeof durationMs !== "number" || durationMs < 0 ? "n/a" : `${durationMs}ms`;
|
|
11244
|
+
var makeTracePanel = (prefix) => ({
|
|
11245
|
+
title,
|
|
11246
|
+
summary,
|
|
11247
|
+
trace
|
|
11248
|
+
}) => {
|
|
11249
|
+
if (!trace) {
|
|
11250
|
+
return "";
|
|
11251
|
+
}
|
|
11252
|
+
const presentation = buildRAGRetrievalTracePresentation(trace);
|
|
11253
|
+
return [
|
|
11254
|
+
`<div class="${prefix}-results">`,
|
|
11255
|
+
`<h4>${escapeHtml(title)}</h4>`,
|
|
11256
|
+
`<p class="${prefix}-metadata">${escapeHtml(summary)}</p>`,
|
|
11257
|
+
`<div class="${prefix}-stat-grid">`,
|
|
11258
|
+
presentation.stats.map((row) => `<article class="${prefix}-stat-card"><p class="${prefix}-section-caption">${escapeHtml(row.label)}</p><strong>${escapeHtml(row.value)}</strong></article>`).join(""),
|
|
11259
|
+
"</div>",
|
|
11260
|
+
"<div>",
|
|
11261
|
+
presentation.details.map((row) => `<p class="${prefix}-key-value-row"><strong>${escapeHtml(row.label)}</strong><span>${escapeHtml(row.value)}</span></p>`).join(""),
|
|
11262
|
+
"</div>",
|
|
11263
|
+
`<div class="${prefix}-result-grid">`,
|
|
11264
|
+
presentation.steps.map((step, index) => `<details class="${prefix}-collapsible ${prefix}-result-item" ${index === 0 ? "open" : ""}><summary><strong>${index + 1}. ${escapeHtml(step.label)}</strong></summary>${step.rows.map((row) => `<p class="${prefix}-key-value-row"><strong>${escapeHtml(row.label)}</strong><span>${escapeHtml(row.value)}</span></p>`).join("")}</details>`).join(""),
|
|
11265
|
+
"</div>",
|
|
11266
|
+
"</div>"
|
|
11267
|
+
].join("");
|
|
11268
|
+
};
|
|
11269
|
+
var makeStageRow = (prefix) => (currentStage) => `<div class="${prefix}-stage-row">${STREAM_STAGES.map((stage) => {
|
|
11270
|
+
const classNames = [`${prefix}-stage-pill`];
|
|
11271
|
+
if (stage === "complete") {
|
|
11272
|
+
classNames.push("complete");
|
|
11273
|
+
}
|
|
11274
|
+
if (stage === currentStage) {
|
|
11275
|
+
classNames.push("current");
|
|
11276
|
+
}
|
|
11277
|
+
return `<span class="${classNames.join(" ")}">${escapeHtml(stage)}</span>`;
|
|
11278
|
+
}).join("")}</div>`;
|
|
11279
|
+
var makeCapabilities = (prefix) => (capabilities) => {
|
|
11280
|
+
if (!capabilities) {
|
|
11281
|
+
return `<p class="${prefix}-metadata">Backend capabilities unavailable.</p>`;
|
|
11282
|
+
}
|
|
11283
|
+
const values = [
|
|
11284
|
+
capabilities.backend,
|
|
11285
|
+
capabilities.persistence,
|
|
11286
|
+
capabilities.nativeVectorSearch ? "native vector search" : "managed fallback search",
|
|
11287
|
+
capabilities.serverSideFiltering ? "server-side filters" : "client-side filters",
|
|
11288
|
+
capabilities.streamingIngestStatus ? "streaming ingest status" : "polled ingest status"
|
|
11289
|
+
];
|
|
11290
|
+
return `<p class="${prefix}-metadata">Backend capabilities: <strong>${escapeHtml(values.join(" \xB7 "))}</strong></p>`;
|
|
11291
|
+
};
|
|
11292
|
+
var defaultNativeSource = (status) => {
|
|
11293
|
+
const native = status?.native;
|
|
11294
|
+
if (!native || !native.active) {
|
|
11295
|
+
return "Not applicable";
|
|
11296
|
+
}
|
|
11297
|
+
if (status?.backend === "sqlite") {
|
|
11298
|
+
return "Packaged sqlite-vec";
|
|
11299
|
+
}
|
|
11300
|
+
if (status?.backend === "postgres") {
|
|
11301
|
+
return "PostgreSQL pgvector extension";
|
|
11302
|
+
}
|
|
11303
|
+
return "Managed by AbsoluteJS";
|
|
11304
|
+
};
|
|
11305
|
+
var defaultStatusSummary = (status) => {
|
|
11306
|
+
if (!status) {
|
|
11307
|
+
return "No backend status is available.";
|
|
11308
|
+
}
|
|
11309
|
+
if (status.native?.active) {
|
|
11310
|
+
return "Native vector acceleration is active.";
|
|
11311
|
+
}
|
|
11312
|
+
if (status.vectorMode === "json_fallback") {
|
|
11313
|
+
return "Owned JSON fallback retrieval is active.";
|
|
11314
|
+
}
|
|
11315
|
+
return `Vector mode ${status.vectorMode} is active.`;
|
|
11316
|
+
};
|
|
11317
|
+
var defaultStatusMessage = (status) => {
|
|
11318
|
+
if (!status) {
|
|
11319
|
+
return "Backend status unavailable.";
|
|
11320
|
+
}
|
|
11321
|
+
return status.native?.fallbackReason ?? defaultStatusSummary(status);
|
|
11322
|
+
};
|
|
11323
|
+
var makeDetailList = (prefix) => (lines, fallback) => {
|
|
11324
|
+
const values = lines.length > 0 ? lines : [fallback];
|
|
11325
|
+
return `<ul class="${prefix}-detail-list">${values.map((line) => `<li>${escapeHtml(line)}</li>`).join("")}</ul>`;
|
|
11326
|
+
};
|
|
11327
|
+
var makeAdminJobCards = (prefix) => (jobs) => {
|
|
11328
|
+
const records = (jobs ?? []).slice(0, 3);
|
|
11329
|
+
if (records.length === 0) {
|
|
11330
|
+
return `<p class="${prefix}-metadata">No admin jobs recorded yet.</p>`;
|
|
11331
|
+
}
|
|
11332
|
+
return `<div class="${prefix}-stat-grid">${records.map((job) => {
|
|
11333
|
+
const target = job.target ?? "global";
|
|
11334
|
+
const timing = typeof job.startedAt === "number" ? formatTime(job.startedAt) : "n/a";
|
|
11335
|
+
return `<article class="${prefix}-stat-card">
|
|
11336
|
+
<span class="${prefix}-stat-label">${escapeHtml(job.action)}</span>
|
|
11337
|
+
<strong>${escapeHtml(job.status.toUpperCase())}</strong>
|
|
11338
|
+
<p>${escapeHtml(target)}</p>
|
|
11339
|
+
<div class="${prefix}-key-value-list">
|
|
11340
|
+
<div class="${prefix}-key-value-row"><span>Started</span><strong>${escapeHtml(timing)}</strong></div>
|
|
11341
|
+
${typeof job.elapsedMs === "number" ? `<div class="${prefix}-key-value-row"><span>Elapsed</span><strong>${escapeHtml(formatDuration(job.elapsedMs))}</strong></div>` : ""}
|
|
11342
|
+
</div>
|
|
11343
|
+
</article>`;
|
|
11344
|
+
}).join("")}</div>`;
|
|
11345
|
+
};
|
|
11346
|
+
var makeAdminActionCards = (prefix) => (actions) => {
|
|
11347
|
+
const records = (actions ?? []).slice(0, 3);
|
|
11348
|
+
if (records.length === 0) {
|
|
11349
|
+
return `<p class="${prefix}-metadata">No admin actions recorded yet.</p>`;
|
|
11350
|
+
}
|
|
11351
|
+
return `<div class="${prefix}-stat-grid">${records.map((action) => {
|
|
11352
|
+
const target = action.documentId ?? action.target ?? "global";
|
|
11353
|
+
const timing = typeof action.elapsedMs === "number" ? formatDuration(action.elapsedMs) : typeof action.startedAt === "number" ? formatTime(action.startedAt) : "n/a";
|
|
11354
|
+
return `<article class="${prefix}-stat-card">
|
|
11355
|
+
<span class="${prefix}-stat-label">${escapeHtml(action.action)}</span>
|
|
11356
|
+
<strong>${escapeHtml(action.status.toUpperCase())}</strong>
|
|
11357
|
+
<p>${escapeHtml(target)}</p>
|
|
11358
|
+
<div class="${prefix}-key-value-list">
|
|
11359
|
+
<div class="${prefix}-key-value-row"><span>When</span><strong>${escapeHtml(timing)}</strong></div>
|
|
11360
|
+
</div>
|
|
11361
|
+
</article>`;
|
|
11362
|
+
}).join("")}</div>`;
|
|
11363
|
+
};
|
|
11364
|
+
var resolveRAGHTMXRenderers = (custom = {}) => {
|
|
11365
|
+
const classPrefix = custom.classPrefix ?? "rag";
|
|
11366
|
+
return {
|
|
11367
|
+
adminActionCards: custom.adminActionCards ?? makeAdminActionCards(classPrefix),
|
|
11368
|
+
adminJobCards: custom.adminJobCards ?? makeAdminJobCards(classPrefix),
|
|
11369
|
+
capabilities: custom.capabilities ?? makeCapabilities(classPrefix),
|
|
11370
|
+
classPrefix,
|
|
11371
|
+
detailList: custom.detailList ?? makeDetailList(classPrefix),
|
|
11372
|
+
nativeSource: custom.nativeSource ?? defaultNativeSource,
|
|
11373
|
+
stageRow: custom.stageRow ?? makeStageRow(classPrefix),
|
|
11374
|
+
statusMessage: custom.statusMessage ?? defaultStatusMessage,
|
|
11375
|
+
statusSummary: custom.statusSummary ?? defaultStatusSummary,
|
|
11376
|
+
tracePanel: custom.tracePanel ?? makeTracePanel(classPrefix)
|
|
11377
|
+
};
|
|
11378
|
+
};
|
|
11224
11379
|
export {
|
|
11225
11380
|
resolveRAGStreamStage,
|
|
11381
|
+
resolveRAGHTMXRenderers,
|
|
11226
11382
|
getLatestRAGSources,
|
|
11227
11383
|
getLatestAssistantMessage,
|
|
11228
11384
|
buildRAGSyncSourcePresentations,
|
|
@@ -11278,5 +11434,5 @@ export {
|
|
|
11278
11434
|
buildRAGAdminActionPresentation
|
|
11279
11435
|
};
|
|
11280
11436
|
|
|
11281
|
-
//# debugId=
|
|
11437
|
+
//# debugId=B8E44E48C030946D64756E2164756E21
|
|
11282
11438
|
//# sourceMappingURL=ui.js.map
|