@absolutejs/rag 0.0.14 → 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 +196 -41
- package/dist/index.js.map +8 -7
- 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/index.d.ts +2 -2
- package/dist/src/presentation/htmxRenderers.d.ts +31 -0
- package/dist/src/presentation/ui.d.ts +2 -0
- package/dist/src/retrieval/context.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/src/types.d.ts +0 -7
package/dist/index.js
CHANGED
|
@@ -11221,6 +11221,161 @@ 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
|
// src/chat/chat.ts
|
|
11225
11380
|
import { Elysia } from "elysia";
|
|
11226
11381
|
|
|
@@ -21131,8 +21286,8 @@ var ingestRAGDocuments = async (collection, input) => collection.ingest(buildRAG
|
|
|
21131
21286
|
var searchDocuments = async (collection, input) => collection.search(input);
|
|
21132
21287
|
|
|
21133
21288
|
// src/presentation/htmxWorkflowRenderers.ts
|
|
21134
|
-
var
|
|
21135
|
-
var renderLabelValueRows = (rows) => rows.length > 0 ? `<dl class="rag-status">${rows.map((row) => `<div><dt>${
|
|
21289
|
+
var escapeHtml2 = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
21290
|
+
var renderLabelValueRows = (rows) => rows.length > 0 ? `<dl class="rag-status">${rows.map((row) => `<div><dt>${escapeHtml2(row.label)}</dt><dd>${escapeHtml2(row.value)}</dd></div>`).join("")}</dl>` : "";
|
|
21136
21291
|
var renderBenchmarkRuntimePanel = (input) => {
|
|
21137
21292
|
const rows = [
|
|
21138
21293
|
{
|
|
@@ -21146,7 +21301,7 @@ var renderBenchmarkRuntimePanel = (input) => {
|
|
|
21146
21301
|
const recentRuns = input.response.historyPresentation?.recentRuns ?? [];
|
|
21147
21302
|
const snapshotRows = input.response.snapshotHistoryPresentation?.rows ?? [];
|
|
21148
21303
|
const snapshots = input.response.snapshotHistoryPresentation?.snapshots ?? [];
|
|
21149
|
-
return `<section class="rag-status-governance"><h3>${
|
|
21304
|
+
return `<section class="rag-status-governance"><h3>${escapeHtml2(input.title)}</h3>` + renderLabelValueRows(rows) + `<h4>Run history</h4>` + renderLabelValueRows(latestRows) + (recentRuns.length > 0 ? `<ul class="rag-status-capabilities">${recentRuns.slice(0, 3).map((run) => `<li><strong>${escapeHtml2(run.label)}</strong> ${escapeHtml2(run.summary)}</li>`).join("")}</ul>` : `<p class="rag-empty">No persisted benchmark runs yet.</p>`) + `<h4>Snapshot history</h4>` + renderLabelValueRows(snapshotRows) + (snapshots.length > 0 ? `<ul class="rag-status-capabilities">${snapshots.slice(0, 3).map((snapshot) => `<li><strong>${escapeHtml2(snapshot.label)}</strong> ${escapeHtml2(snapshot.summary)}</li>`).join("")}</ul>` : `<p class="rag-empty">No saved suite snapshots yet.</p>`) + `</section>`;
|
|
21150
21305
|
};
|
|
21151
21306
|
var renderBenchmarkSnapshotPanel = (input) => {
|
|
21152
21307
|
const summaryRows = [
|
|
@@ -21161,16 +21316,16 @@ var renderBenchmarkSnapshotPanel = (input) => {
|
|
|
21161
21316
|
].filter((row) => Boolean(row));
|
|
21162
21317
|
const snapshotRows = input.response.snapshotHistoryPresentation?.rows ?? [];
|
|
21163
21318
|
const snapshots = input.response.snapshotHistoryPresentation?.snapshots ?? [];
|
|
21164
|
-
return `<section class="rag-status-governance"><h3>${
|
|
21319
|
+
return `<section class="rag-status-governance"><h3>${escapeHtml2(input.title)}</h3>` + renderLabelValueRows(summaryRows) + renderLabelValueRows(snapshotRows) + (snapshots.length > 0 ? `<ul class="rag-status-capabilities">${snapshots.slice(0, 3).map((snapshot) => `<li><strong>${escapeHtml2(snapshot.label)}</strong> ${escapeHtml2(snapshot.summary)}</li>`).join("")}</ul>` : `<p class="rag-empty">No saved suite snapshots yet.</p>`) + `</section>`;
|
|
21165
21320
|
};
|
|
21166
21321
|
var renderSourceLabels = (input) => {
|
|
21167
21322
|
if (!input) {
|
|
21168
21323
|
return "";
|
|
21169
21324
|
}
|
|
21170
21325
|
const rows = [
|
|
21171
|
-
input.contextLabel ? `<li><strong>Context</strong> ${
|
|
21172
|
-
input.locatorLabel ? `<li><strong>Location</strong> ${
|
|
21173
|
-
input.provenanceLabel ? `<li><strong>Provenance</strong> ${
|
|
21326
|
+
input.contextLabel ? `<li><strong>Context</strong> ${escapeHtml2(input.contextLabel)}</li>` : "",
|
|
21327
|
+
input.locatorLabel ? `<li><strong>Location</strong> ${escapeHtml2(input.locatorLabel)}</li>` : "",
|
|
21328
|
+
input.provenanceLabel ? `<li><strong>Provenance</strong> ${escapeHtml2(input.provenanceLabel)}</li>` : ""
|
|
21174
21329
|
].filter((row) => row.length > 0);
|
|
21175
21330
|
return rows.length > 0 ? `<ul class="rag-source-labels">${rows.join("")}</ul>` : "";
|
|
21176
21331
|
};
|
|
@@ -21199,12 +21354,12 @@ var renderChunkStructure = (structure) => {
|
|
|
21199
21354
|
return "";
|
|
21200
21355
|
}
|
|
21201
21356
|
const rows = [
|
|
21202
|
-
structure.section?.kind ? `<li><strong>Kind</strong> ${
|
|
21203
|
-
structure.section?.title ? `<li><strong>Section</strong> ${
|
|
21204
|
-
structure.section?.path && structure.section.path.length > 1 ? `<li><strong>Section path</strong> ${
|
|
21357
|
+
structure.section?.kind ? `<li><strong>Kind</strong> ${escapeHtml2(formatStructureKindLabel(structure.section.kind) ?? structure.section.kind)}</li>` : "",
|
|
21358
|
+
structure.section?.title ? `<li><strong>Section</strong> ${escapeHtml2(structure.section.title)}</li>` : "",
|
|
21359
|
+
structure.section?.path && structure.section.path.length > 1 ? `<li><strong>Section path</strong> ${escapeHtml2(structure.section.path.join(" > "))}</li>` : "",
|
|
21205
21360
|
typeof structure.sequence?.sectionChunkIndex === "number" && typeof structure.sequence?.sectionChunkCount === "number" ? `<li><strong>Section chunk</strong> ${structure.sequence.sectionChunkIndex + 1} of ${structure.sequence.sectionChunkCount}</li>` : "",
|
|
21206
|
-
structure.sequence?.previousChunkId ? `<li><strong>Previous</strong> ${
|
|
21207
|
-
structure.sequence?.nextChunkId ? `<li><strong>Next</strong> ${
|
|
21361
|
+
structure.sequence?.previousChunkId ? `<li><strong>Previous</strong> ${escapeHtml2(structure.sequence.previousChunkId)}</li>` : "",
|
|
21362
|
+
structure.sequence?.nextChunkId ? `<li><strong>Next</strong> ${escapeHtml2(structure.sequence.nextChunkId)}</li>` : ""
|
|
21208
21363
|
].filter((row) => row.length > 0);
|
|
21209
21364
|
return rows.length > 0 ? `<ul class="rag-chunk-structure">${rows.join("")}</ul>` : "";
|
|
21210
21365
|
};
|
|
@@ -21213,9 +21368,9 @@ var renderChunkExcerpts = (input) => {
|
|
|
21213
21368
|
return "";
|
|
21214
21369
|
}
|
|
21215
21370
|
const rows = [
|
|
21216
|
-
input.chunkExcerpt ? `<li><strong>Chunk excerpt</strong> ${
|
|
21217
|
-
input.windowExcerpt ? `<li><strong>Neighbor window</strong> ${
|
|
21218
|
-
input.sectionExcerpt ? `<li><strong>Section excerpt</strong> ${
|
|
21371
|
+
input.chunkExcerpt ? `<li><strong>Chunk excerpt</strong> ${escapeHtml2(input.chunkExcerpt)}</li>` : "",
|
|
21372
|
+
input.windowExcerpt ? `<li><strong>Neighbor window</strong> ${escapeHtml2(input.windowExcerpt)}</li>` : "",
|
|
21373
|
+
input.sectionExcerpt ? `<li><strong>Section excerpt</strong> ${escapeHtml2(input.sectionExcerpt)}</li>` : ""
|
|
21219
21374
|
].filter((row) => row.length > 0);
|
|
21220
21375
|
return rows.length > 0 ? `<ul class="rag-chunk-structure">${rows.join("")}</ul>` : "";
|
|
21221
21376
|
};
|
|
@@ -21225,17 +21380,17 @@ var renderExcerptSelection = (selection) => {
|
|
|
21225
21380
|
}
|
|
21226
21381
|
const modeLabel = selection.mode === "chunk" ? "Chunk excerpt" : selection.mode === "window" ? "Neighbor window" : "Section excerpt";
|
|
21227
21382
|
const reasonLabel = selection.reason === "single_chunk" ? "single chunk" : selection.reason === "chunk_too_narrow" ? "chunk too narrow" : selection.reason === "section_small_enough" ? "section small enough" : "section too large, used window";
|
|
21228
|
-
return `<ul class="rag-chunk-structure"><li><strong>Preferred excerpt</strong> ${
|
|
21383
|
+
return `<ul class="rag-chunk-structure"><li><strong>Preferred excerpt</strong> ${escapeHtml2(modeLabel)}</li><li><strong>Promotion reason</strong> ${escapeHtml2(reasonLabel)}</li></ul>`;
|
|
21229
21384
|
};
|
|
21230
21385
|
var renderSectionJumpList = (label, items) => {
|
|
21231
|
-
const rows = items.map((item) => item.href ? `<li><strong>${
|
|
21386
|
+
const rows = items.map((item) => item.href ? `<li><strong>${escapeHtml2(label)}</strong> <a href="${escapeHtml2(item.href)}"${item.active ? ' aria-current="true"' : ""}>${escapeHtml2(item.label)}</a></li>` : `<li><strong>${escapeHtml2(label)}</strong> ${escapeHtml2(item.label)}</li>`).join("");
|
|
21232
21387
|
return rows ? `<ul class="rag-chunk-structure">${rows}</ul>` : "";
|
|
21233
21388
|
};
|
|
21234
21389
|
var renderSectionDiagnostics = (diagnostics) => {
|
|
21235
21390
|
if (diagnostics.length === 0) {
|
|
21236
21391
|
return "";
|
|
21237
21392
|
}
|
|
21238
|
-
return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${
|
|
21393
|
+
return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${escapeHtml2(diagnostic.key)}">` + `<h4>${escapeHtml2(diagnostic.path?.join(" > ") ?? diagnostic.label)}</h4>` + `<p class="rag-search-source">${escapeHtml2(diagnostic.summary)}</p>` + `<ul class="rag-source-labels">` + `<li><strong>Top hit</strong> ${diagnostic.bestScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Average</strong> ${diagnostic.averageScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Sources</strong> ${diagnostic.sourceCount}</li>` + `<li><strong>Channels</strong> vector ${diagnostic.vectorHits} \xB7 lexical ${diagnostic.lexicalHits} \xB7 hybrid ${diagnostic.hybridHits}</li>` + `${diagnostic.topContextLabel ? `<li><strong>Lead context</strong> ${escapeHtml2(diagnostic.topContextLabel)}</li>` : ""}` + `${diagnostic.topLocatorLabel ? `<li><strong>Lead location</strong> ${escapeHtml2(diagnostic.topLocatorLabel)}</li>` : ""}` + `${diagnostic.sourceAwareChunkReasonLabel ? `<li><strong>Chunk boundary</strong> ${escapeHtml2(diagnostic.sourceAwareChunkReasonLabel)}</li>` : ""}` + `${diagnostic.sourceAwareUnitScopeLabel ? `<li><strong>Source-aware scope</strong> ${escapeHtml2(diagnostic.sourceAwareUnitScopeLabel)}</li>` : ""}` + `${diagnostic.stageCounts.length > 0 ? `<li><strong>Stage flow</strong> ${escapeHtml2(diagnostic.stageCounts.map((entry) => `${entry.stage} ${entry.count}`).join(" \u2192 "))}</li>` : ""}` + `${diagnostic.firstSeenStage ? `<li><strong>First seen</strong> ${escapeHtml2(diagnostic.firstSeenStage)}</li>` : ""}` + `${diagnostic.lastSeenStage ? `<li><strong>Last seen</strong> ${escapeHtml2(diagnostic.lastSeenStage)}</li>` : ""}` + `<li><strong>Query attribution</strong> ${escapeHtml2(`${diagnostic.queryAttribution.mode} \xB7 primary ${diagnostic.queryAttribution.primaryHits} \xB7 transformed ${diagnostic.queryAttribution.transformedHits} \xB7 variant ${diagnostic.queryAttribution.variantHits}`)}</li>` + `${diagnostic.queryAttribution.reasons.length > 0 ? `<li><strong>Query attribution reasons</strong> ${escapeHtml2(diagnostic.queryAttribution.reasons.join(", "))}</li>` : ""}` + `${diagnostic.peakStage ? `<li><strong>Peak stage</strong> ${escapeHtml2(diagnostic.peakStage)} (${diagnostic.peakCount})</li>` : ""}` + `${typeof diagnostic.finalRetentionRate === "number" ? `<li><strong>Final retention</strong> ${(diagnostic.finalRetentionRate * 100).toFixed(0)}%</li>` : ""}` + `${typeof diagnostic.dropFromPeak === "number" ? `<li><strong>Drop from peak</strong> ${diagnostic.dropFromPeak}</li>` : ""}` + `${diagnostic.retrievalMode ? `<li><strong>Trace mode</strong> ${escapeHtml2(diagnostic.retrievalMode)}</li>` : ""}` + `${diagnostic.rerankApplied !== undefined ? `<li><strong>Rerank</strong> ${diagnostic.rerankApplied ? "applied" : "skipped"}</li>` : ""}` + `${diagnostic.sourceBalanceApplied ? `<li><strong>Source balance</strong> applied</li>` : ""}` + `${diagnostic.scoreThresholdApplied ? `<li><strong>Score threshold</strong> applied</li>` : ""}` + `<li><strong>Reasons</strong> ${escapeHtml2(diagnostic.reasons.join(", ") || "none")}</li>` + `${diagnostic.strongestSiblingLabel ? `<li><strong>Strongest sibling</strong> ${escapeHtml2(diagnostic.strongestSiblingLabel)} (${diagnostic.strongestSiblingScore?.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES) ?? "n/a"})</li>` : ""}` + `${typeof diagnostic.parentShareGap === "number" ? `<li><strong>Parent share gap</strong> ${(diagnostic.parentShareGap * 100).toFixed(0)}%</li>` : ""}` + `</ul>` + `${diagnostic.stageWeights.length > 0 ? `<ul class="rag-source-labels">${diagnostic.stageWeights.map((entry) => `<li><strong>${escapeHtml2(entry.stage)}</strong> ${(entry.stageShare * 100).toFixed(0)}% of stage` + `${typeof entry.retentionRate === "number" ? ` \xB7 ${(entry.retentionRate * 100).toFixed(0)}% retained from ${escapeHtml2(entry.previousStage ?? "previous")}` : ""}` + `${typeof entry.countDelta === "number" ? ` \xB7 delta ${entry.countDelta >= 0 ? "+" : ""}${entry.countDelta}` : ""}` + `${typeof entry.stageScoreShare === "number" ? ` \xB7 ${(entry.stageScoreShare * 100).toFixed(0)}% of stage score` : ""}` + `${typeof entry.parentStageScoreShare === "number" ? ` \xB7 ${(entry.parentStageScoreShare * 100).toFixed(0)}% of parent stage score` : ""}` + `${typeof entry.stageScoreShareGap === "number" ? ` \xB7 score gap ${(entry.stageScoreShareGap * 100).toFixed(0)}%` : ""}` + `${typeof entry.parentStageShare === "number" ? ` \xB7 ${(entry.parentStageShare * 100).toFixed(0)}% of parent stage` : ""}` + `${typeof entry.stageShareGap === "number" ? ` \xB7 gap ${(entry.stageShareGap * 100).toFixed(0)}%` : ""}` + `${entry.strongestSiblingLabel ? ` \xB7 runner-up ${escapeHtml2(entry.strongestSiblingLabel)}` : ""}` + `${entry.reasons.length > 0 ? ` \xB7 ${escapeHtml2(entry.reasons.join(", "))}` : ""}</li>`).join("")}</ul>` : ""}` + `${diagnostic.parentDistribution.length > 0 ? `<ul class="rag-source-labels">${diagnostic.parentDistribution.map((entry) => `<li><strong>${entry.isActive ? "Active section" : "Peer section"}</strong> ${escapeHtml2(entry.label)} \xB7 ${(entry.parentShare * 100).toFixed(0)}% \xB7 ${entry.count} hit${entry.count === 1 ? "" : "s"}</li>`).join("")}</ul>` : ""}` + `</article>`).join("") + `</section>`;
|
|
21239
21394
|
};
|
|
21240
21395
|
var renderEmptyState = (kind) => {
|
|
21241
21396
|
switch (kind) {
|
|
@@ -21264,7 +21419,7 @@ var renderCapabilityList = (capabilities) => {
|
|
|
21264
21419
|
`serverSideFiltering=${capabilities.serverSideFiltering ? "true" : "false"}`,
|
|
21265
21420
|
`streamingIngestStatus=${capabilities.streamingIngestStatus ? "true" : "false"}`
|
|
21266
21421
|
];
|
|
21267
|
-
return `<ul class="rag-status-capabilities">${items.map((item) => `<li>${
|
|
21422
|
+
return `<ul class="rag-status-capabilities">${items.map((item) => `<li>${escapeHtml2(item)}</li>`).join("")}</ul>`;
|
|
21268
21423
|
};
|
|
21269
21424
|
var formatByteSize = (value) => {
|
|
21270
21425
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
@@ -21292,7 +21447,7 @@ var renderPostgresNativeStatus = (status) => {
|
|
|
21292
21447
|
status.native.lastReindexError ? `Native index rebuild failed: ${status.native.lastReindexError}` : "",
|
|
21293
21448
|
typeof status.native.indexBytes === "number" && typeof status.native.totalBytes === "number" && status.native.totalBytes > 0 && status.native.indexBytes / status.native.totalBytes >= 0.7 ? "Index-heavy storage footprint" : ""
|
|
21294
21449
|
].filter((entry) => entry.length > 0);
|
|
21295
|
-
return `<dl class="rag-status">` + `<div><dt>Index type</dt><dd>${
|
|
21450
|
+
return `<dl class="rag-status">` + `<div><dt>Index type</dt><dd>${escapeHtml2(status.native.indexType ?? "n/a")}</dd></div>` + `<div><dt>Index name</dt><dd>${escapeHtml2(status.native.indexName ?? "n/a")}</dd></div>` + `<div><dt>Index present</dt><dd>${typeof status.native.indexPresent === "boolean" ? status.native.indexPresent ? "true" : "false" : "n/a"}</dd></div>` + `<div><dt>Estimated rows</dt><dd>${typeof status.native.estimatedRowCount === "number" ? String(status.native.estimatedRowCount) : "n/a"}</dd></div>` + `<div><dt>Table bytes</dt><dd>${formatByteSize(status.native.tableBytes)}</dd></div>` + `<div><dt>Index bytes</dt><dd>${formatByteSize(status.native.indexBytes)}</dd></div>` + `<div><dt>Total bytes</dt><dd>${formatByteSize(status.native.totalBytes)}</dd></div>` + `<div><dt>Health check</dt><dd>${typeof status.native.lastHealthCheckAt === "number" ? escapeHtml2(new Date(status.native.lastHealthCheckAt).toLocaleString("en-US")) : "n/a"}</dd></div>` + `<div><dt>Last analyze</dt><dd>${typeof status.native.lastAnalyzeAt === "number" ? escapeHtml2(new Date(status.native.lastAnalyzeAt).toLocaleString("en-US")) : "n/a"}</dd></div>` + `<div><dt>Last index rebuild</dt><dd>${typeof status.native.lastReindexAt === "number" ? escapeHtml2(new Date(status.native.lastReindexAt).toLocaleString("en-US")) : "n/a"}</dd></div>` + `</dl>` + (warnings.length > 0 ? `<ul class="rag-status-capabilities">${warnings.map((warning) => `<li>${escapeHtml2(warning)}</li>`).join("")}</ul>` : "");
|
|
21296
21451
|
};
|
|
21297
21452
|
var renderSQLiteNativeStatus = (status) => {
|
|
21298
21453
|
if (status?.backend !== "sqlite" || !status.native || !("mode" in status.native) || status.native.mode !== "vec0") {
|
|
@@ -21304,15 +21459,15 @@ var renderSQLiteNativeStatus = (status) => {
|
|
|
21304
21459
|
status.native.lastAnalyzeError ? `Analyze failed: ${status.native.lastAnalyzeError}` : "",
|
|
21305
21460
|
typeof status.native.pageCount === "number" && typeof status.native.freelistCount === "number" && status.native.pageCount > 0 && status.native.freelistCount / status.native.pageCount >= 0.2 ? "SQLite freelist growth suggests running optimize" : ""
|
|
21306
21461
|
].filter((entry) => entry.length > 0);
|
|
21307
|
-
return `<dl class="rag-status">` + `<div><dt>Native table</dt><dd>${
|
|
21462
|
+
return `<dl class="rag-status">` + `<div><dt>Native table</dt><dd>${escapeHtml2(status.native.tableName ?? "n/a")}</dd></div>` + `<div><dt>Distance metric</dt><dd>${escapeHtml2(status.native.distanceMetric ?? "n/a")}</dd></div>` + `<div><dt>Native active</dt><dd>${status.native.active ? "true" : "false"}</dd></div>` + `<div><dt>Row count</dt><dd>${typeof status.native.rowCount === "number" ? String(status.native.rowCount) : "n/a"}</dd></div>` + `<div><dt>Database bytes</dt><dd>${formatByteSize(status.native.databaseBytes)}</dd></div>` + `<div><dt>Page count</dt><dd>${typeof status.native.pageCount === "number" ? String(status.native.pageCount) : "n/a"}</dd></div>` + `<div><dt>Freelist pages</dt><dd>${typeof status.native.freelistCount === "number" ? String(status.native.freelistCount) : "n/a"}</dd></div>` + `<div><dt>Health check</dt><dd>${typeof status.native.lastHealthCheckAt === "number" ? escapeHtml2(new Date(status.native.lastHealthCheckAt).toLocaleString("en-US")) : "n/a"}</dd></div>` + `<div><dt>Last analyze</dt><dd>${typeof status.native.lastAnalyzeAt === "number" ? escapeHtml2(new Date(status.native.lastAnalyzeAt).toLocaleString("en-US")) : "n/a"}</dd></div>` + `</dl>` + (warnings.length > 0 ? `<ul class="rag-status-capabilities">${warnings.map((warning) => `<li>${escapeHtml2(warning)}</li>`).join("")}</ul>` : "");
|
|
21308
21463
|
};
|
|
21309
21464
|
var renderStatusActions = (input) => {
|
|
21310
21465
|
if (!input.path) {
|
|
21311
21466
|
return "";
|
|
21312
21467
|
}
|
|
21313
21468
|
const actions = [
|
|
21314
|
-
input.admin?.canAnalyzeBackend ? `<button type="button" hx-post="${
|
|
21315
|
-
input.status?.backend === "postgres" && input.admin?.canRebuildNativeIndex ? `<button type="button" hx-post="${
|
|
21469
|
+
input.admin?.canAnalyzeBackend ? `<button type="button" hx-post="${escapeHtml2(`${input.path}/backend/analyze`)}" hx-target="#rag-status-feedback" hx-swap="innerHTML">Analyze backend</button>` : "",
|
|
21470
|
+
input.status?.backend === "postgres" && input.admin?.canRebuildNativeIndex ? `<button type="button" hx-post="${escapeHtml2(`${input.path}/backend/reindex-native`)}" hx-target="#rag-status-feedback" hx-swap="innerHTML">Rebuild native index</button>` : ""
|
|
21316
21471
|
].filter((entry) => entry.length > 0);
|
|
21317
21472
|
if (actions.length === 0) {
|
|
21318
21473
|
return "";
|
|
@@ -21339,7 +21494,7 @@ var renderBackendMaintenance = (input) => {
|
|
|
21339
21494
|
if (recommendations.length === 0 && activeJobs.length === 0 && recentActions.length === 0) {
|
|
21340
21495
|
return "";
|
|
21341
21496
|
}
|
|
21342
|
-
return `<section class="rag-status-maintenance">` + `<h3>Backend maintenance</h3>` + (recommendations.length > 0 ? `<ul class="rag-status-capabilities">${recommendations.map((entry) => `<li>${
|
|
21497
|
+
return `<section class="rag-status-maintenance">` + `<h3>Backend maintenance</h3>` + (recommendations.length > 0 ? `<ul class="rag-status-capabilities">${recommendations.map((entry) => `<li>${escapeHtml2(entry)}</li>`).join("")}</ul>` : '<p class="rag-empty">No immediate maintenance recommendations.</p>') + (activeJobs.length > 0 ? `<ul class="rag-status-capabilities">${activeJobs.map((job) => `<li><strong>Running</strong> ${escapeHtml2(job.action)}${job.target ? ` \xB7 ${escapeHtml2(job.target)}` : ""}</li>`).join("")}</ul>` : "") + (recentActions.length > 0 ? `<ul class="rag-status-capabilities">${recentActions.map((action) => `<li><strong>${escapeHtml2(action.action)}</strong> ${escapeHtml2(action.status)}${typeof action.finishedAt === "number" ? ` \xB7 ${escapeHtml2(new Date(action.finishedAt).toLocaleString("en-US"))}` : ""}${action.error ? ` \xB7 ${escapeHtml2(action.error)}` : ""}</li>`).join("")}</ul>` : "") + `</section>`;
|
|
21343
21498
|
};
|
|
21344
21499
|
var renderMaintenancePanel = (input) => {
|
|
21345
21500
|
input.maintenance;
|
|
@@ -21350,7 +21505,7 @@ var renderMaintenancePanel = (input) => {
|
|
|
21350
21505
|
status: input.status
|
|
21351
21506
|
}) || (input.status && input.status.backend !== "in_memory" ? `<section class="rag-status-maintenance"><h3>Backend maintenance</h3><p class="rag-empty">No immediate maintenance recommendations.</p></section>` : renderEmptyState("status"));
|
|
21352
21507
|
const route = input.path ? `${input.path}/status/maintenance` : undefined;
|
|
21353
|
-
return route ? `<div id="rag-status-maintenance-panel" hx-get="${
|
|
21508
|
+
return route ? `<div id="rag-status-maintenance-panel" hx-get="${escapeHtml2(route)}" hx-trigger="load, rag:mutated from:body" hx-swap="outerHTML">${content}</div>` : `<div id="rag-status-maintenance-panel">${content}</div>`;
|
|
21354
21509
|
};
|
|
21355
21510
|
var renderRetrievalGovernancePanel = (retrievalComparisons) => {
|
|
21356
21511
|
if (!retrievalComparisons?.latest && !retrievalComparisons?.alerts?.length) {
|
|
@@ -21360,9 +21515,9 @@ var renderRetrievalGovernancePanel = (retrievalComparisons) => {
|
|
|
21360
21515
|
const alerts = (retrievalComparisons.alerts ?? []).slice(0, 3);
|
|
21361
21516
|
const releaseGroups = (retrievalComparisons.releaseGroups ?? []).slice(0, 2);
|
|
21362
21517
|
const formatClassification = (classification) => classification === "multivector" ? "multivector regression" : classification === "evidence" ? "evidence regression" : classification === "cue" ? "cue regression" : classification === "runtime" ? "runtime regression" : classification === "general" ? "general regression" : undefined;
|
|
21363
|
-
return `<section class="rag-status-governance"><h3>Retrieval governance</h3>` + (latest ? `<dl class="rag-status">` + `<div><dt>Latest comparison</dt><dd>${
|
|
21518
|
+
return `<section class="rag-status-governance"><h3>Retrieval governance</h3>` + (latest ? `<dl class="rag-status">` + `<div><dt>Latest comparison</dt><dd>${escapeHtml2(latest.label)}</dd></div>` + (latest.bestByPassingRate ? `<div><dt>Best passing rate</dt><dd>${escapeHtml2(latest.bestByPassingRate)}</dd></div>` : "") + (latest.bestByAverageF1 ? `<div><dt>Best average F1</dt><dd>${escapeHtml2(latest.bestByAverageF1)}</dd></div>` : "") + (latest.bestByMultivectorCollapsedCases ? `<div><dt>Best multivector collapse</dt><dd>${escapeHtml2(latest.bestByMultivectorCollapsedCases)}</dd></div>` : "") + (latest.bestByMultivectorLexicalHitCases ? `<div><dt>Best multivector lexical hits</dt><dd>${escapeHtml2(latest.bestByMultivectorLexicalHitCases)}</dd></div>` : "") + (latest.bestByMultivectorVectorHitCases ? `<div><dt>Best multivector vector hits</dt><dd>${escapeHtml2(latest.bestByMultivectorVectorHitCases)}</dd></div>` : "") + (latest.decisionSummary?.gate?.status ? `<div><dt>Gate</dt><dd>${escapeHtml2(latest.decisionSummary.gate.status)}</dd></div>` : "") + (latest.releaseVerdict?.status ? `<div><dt>Verdict</dt><dd>${escapeHtml2(latest.releaseVerdict.status)}</dd></div>` : "") + `</dl>` : "") + `<h4>Active alerts</h4>` + (alerts.length > 0 ? `<ul class="rag-status-capabilities">${alerts.map((alert) => `<li><strong>${escapeHtml2(alert.kind)}</strong>${formatClassification(alert.classification) ? ` <span>${escapeHtml2(formatClassification(alert.classification) ?? "")}</span>` : ""} ${escapeHtml2(alert.message)}</li>`).join("")}</ul>` : `<p class="rag-empty">No active retrieval comparison alerts.</p>`) + (releaseGroups.length > 0 ? `<h4>Release groups</h4><ul class="rag-status-capabilities">${releaseGroups.map((group) => {
|
|
21364
21519
|
const reasons = group.recommendedActionReasons?.slice(0, 2).join("; ") ?? "No recommended action.";
|
|
21365
|
-
return `<li><strong>${
|
|
21520
|
+
return `<li><strong>${escapeHtml2(group.groupKey)}</strong>${formatClassification(group.classification) ? ` <span>${escapeHtml2(formatClassification(group.classification) ?? "")}</span>` : ""} ${escapeHtml2(group.recommendedAction ?? "monitor")} \xB7 ${escapeHtml2(reasons)}</li>`;
|
|
21366
21521
|
}).join("")}</ul>` : "") + `</section>`;
|
|
21367
21522
|
};
|
|
21368
21523
|
var defaultStatus = ({
|
|
@@ -21379,7 +21534,7 @@ var defaultStatus = ({
|
|
|
21379
21534
|
if (!status) {
|
|
21380
21535
|
return renderEmptyState("status");
|
|
21381
21536
|
}
|
|
21382
|
-
return `<section class="rag-status-panel">` + `<dl class="rag-status">` + `<div><dt>Backend</dt><dd>${
|
|
21537
|
+
return `<section class="rag-status-panel">` + `<dl class="rag-status">` + `<div><dt>Backend</dt><dd>${escapeHtml2(status.backend)}</dd></div>` + `<div><dt>Vector mode</dt><dd>${escapeHtml2(status.vectorMode)}</dd></div>` + `<div><dt>Embedding dimensions</dt><dd>${status.dimensions ?? "n/a"}</dd></div>` + `<div><dt>Vector acceleration</dt><dd>${status.native?.active ? "active" : "inactive"}</dd></div>` + `<div><dt>Documents</dt><dd>${documents?.total ?? "n/a"}</dd></div>` + `<div><dt>Total chunks</dt><dd>${documents?.chunkCount ?? "n/a"}</dd></div>` + `<div><dt>Seed docs</dt><dd>${documents?.byKind.seed ?? 0}</dd></div>` + `<div><dt>Custom docs</dt><dd>${documents?.byKind.custom ?? 0}</dd></div>` + `</dl>${renderPostgresNativeStatus(status)}${renderSQLiteNativeStatus(status)}${renderRetrievalGovernancePanel(retrievalComparisons)}${renderMaintenancePanel({
|
|
21383
21538
|
admin,
|
|
21384
21539
|
adminActions,
|
|
21385
21540
|
adminJobs,
|
|
@@ -21392,7 +21547,7 @@ var defaultStatus = ({
|
|
|
21392
21547
|
status
|
|
21393
21548
|
})}</section>`;
|
|
21394
21549
|
};
|
|
21395
|
-
var defaultSearchResultItem = (source, index, sectionJumps = "") => `<article class="rag-search-result" id="rag-search-result-${
|
|
21550
|
+
var defaultSearchResultItem = (source, index, sectionJumps = "") => `<article class="rag-search-result" id="rag-search-result-${escapeHtml2(source.chunkId)}">` + `<h3>${escapeHtml2(source.title ?? source.chunkId ?? `Result ${index + 1}`)}</h3>` + `<p class="rag-search-source">${escapeHtml2(source.source ?? "unknown source")}</p>` + renderSourceLabels(source.labels) + renderChunkStructure(source.structure) + sectionJumps + `<p class="rag-search-score">score ${source.score.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</p>` + `<p class="rag-search-text">${escapeHtml2(source.text)}</p>` + "</article>";
|
|
21396
21551
|
var defaultSearchResults = ({
|
|
21397
21552
|
query,
|
|
21398
21553
|
results,
|
|
@@ -21401,7 +21556,7 @@ var defaultSearchResults = ({
|
|
|
21401
21556
|
const graph = buildRAGChunkGraph(results);
|
|
21402
21557
|
const sectionDiagnostics = buildRAGSectionRetrievalDiagnostics(results, trace);
|
|
21403
21558
|
const availableChunkIds = new Set(results.map((result) => result.chunkId));
|
|
21404
|
-
return `<section class="rag-search-results">` + `<p class="rag-search-summary">${results.length} results for ${
|
|
21559
|
+
return `<section class="rag-search-results">` + `<p class="rag-search-summary">${results.length} results for ${escapeHtml2(query)}</p>` + `<p class="rag-search-summary">sections=${sectionDiagnostics.length}</p>` + (trace ? `<p class="rag-search-summary">mode=${escapeHtml2(trace.mode)} \xB7 final=${trace.resultCounts.final} \xB7 vector=${trace.resultCounts.vector} \xB7 lexical=${trace.resultCounts.lexical}</p>` : "") + renderSectionDiagnostics(sectionDiagnostics) + `${results.map((result, index) => {
|
|
21405
21560
|
const navigation = buildRAGChunkGraphNavigation(graph, result.chunkId);
|
|
21406
21561
|
const sectionJumps = [
|
|
21407
21562
|
navigation.parentSection?.leadChunkId ? renderSectionJumpList("Parent section", [
|
|
@@ -21455,7 +21610,7 @@ var defaultSpreadsheetCueBenchmarkSnapshot = (input) => renderBenchmarkSnapshotP
|
|
|
21455
21610
|
response: input,
|
|
21456
21611
|
title: "Spreadsheet cue snapshots"
|
|
21457
21612
|
});
|
|
21458
|
-
var defaultDocumentItem = (document, index) => '<article class="rag-document">' + `<h3>${
|
|
21613
|
+
var defaultDocumentItem = (document, index) => '<article class="rag-document">' + `<h3>${escapeHtml2(document.title || `Document ${index + 1}`)}</h3>` + `<p class="rag-document-id">${escapeHtml2(document.id)}</p>` + `<p class="rag-document-source">${escapeHtml2(document.source)}</p>` + renderSourceLabels(document.labels) + `<p class="rag-document-meta">${escapeHtml2(document.format ?? "text")} \xB7 ${escapeHtml2(document.chunkStrategy ?? "paragraphs")} \xB7 ${document.chunkCount ?? 0} chunks</p>` + "</article>";
|
|
21459
21614
|
var defaultDocuments = ({
|
|
21460
21615
|
documents
|
|
21461
21616
|
}) => documents.length === 0 ? renderEmptyState("documents") : `<section class="rag-documents">${documents.map((document, index) => defaultDocumentItem(document, index)).join("")}</section>`;
|
|
@@ -21481,10 +21636,10 @@ var defaultChunkPreview = (input) => {
|
|
|
21481
21636
|
return acc;
|
|
21482
21637
|
}, []);
|
|
21483
21638
|
const groupHtml = groups.map((group) => {
|
|
21484
|
-
const chunkHtml = group.chunks.map((chunk) => '<article class="rag-chunk">' + `<h5>${
|
|
21485
|
-
return `<section class="rag-chunk-group"><h4>${
|
|
21639
|
+
const chunkHtml = group.chunks.map((chunk) => '<article class="rag-chunk">' + `<h5>${escapeHtml2(chunk.chunkId)}</h5>` + `<p class="rag-chunk-meta">chunk ${typeof chunk.metadata?.chunkIndex === "number" ? chunk.metadata.chunkIndex : 0} of ${typeof chunk.metadata?.chunkCount === "number" ? chunk.metadata.chunkCount : input.chunks.length}</p>` + renderSourceLabels(chunk.labels) + renderChunkStructure(chunk.structure) + renderChunkExcerpts(chunk.excerpts) + renderExcerptSelection(chunk.excerptSelection) + `<pre>${escapeHtml2(chunk.text)}</pre>` + "</article>").join("");
|
|
21640
|
+
return `<section class="rag-chunk-group"><h4>${escapeHtml2(group.title)}</h4>${chunkHtml}</section>`;
|
|
21486
21641
|
}).join("");
|
|
21487
|
-
return `<section class="rag-chunk-preview">` + `<h3>${
|
|
21642
|
+
return `<section class="rag-chunk-preview">` + `<h3>${escapeHtml2(input.document.title)}</h3>` + `<p class="rag-chunk-preview-source">${escapeHtml2(input.document.source)}</p>` + renderSourceLabels(input.document.labels) + (navigation.parentSection ? renderSectionJumpList("Parent section", [
|
|
21488
21643
|
{
|
|
21489
21644
|
label: navigation.parentSection.title ?? navigation.parentSection.path?.join(" > ") ?? navigation.parentSection.id
|
|
21490
21645
|
}
|
|
@@ -21492,11 +21647,11 @@ var defaultChunkPreview = (input) => {
|
|
|
21492
21647
|
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
21493
21648
|
}))) : "") + (navigation.childSections.length > 0 ? renderSectionJumpList("Child section", navigation.childSections.map((section) => ({
|
|
21494
21649
|
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
21495
|
-
}))) : "") + `<article class="rag-chunk-normalized">` + `<h4>Normalized text</h4>` + `<pre>${
|
|
21650
|
+
}))) : "") + `<article class="rag-chunk-normalized">` + `<h4>Normalized text</h4>` + `<pre>${escapeHtml2(input.normalizedText)}</pre>` + `</article>${groupHtml}</section>`;
|
|
21496
21651
|
};
|
|
21497
21652
|
var defaultMutationResult = (input) => {
|
|
21498
21653
|
if (!input.ok) {
|
|
21499
|
-
return `<div class="rag-mutation error">${
|
|
21654
|
+
return `<div class="rag-mutation error">${escapeHtml2(input.error ?? "Request failed")}</div>`;
|
|
21500
21655
|
}
|
|
21501
21656
|
const details = [];
|
|
21502
21657
|
if (input.status) {
|
|
@@ -21511,7 +21666,7 @@ var defaultMutationResult = (input) => {
|
|
|
21511
21666
|
if (typeof input.documents === "number") {
|
|
21512
21667
|
details.push(`documents=${input.documents}`);
|
|
21513
21668
|
}
|
|
21514
|
-
return `<div class="rag-mutation ok">${
|
|
21669
|
+
return `<div class="rag-mutation ok">${escapeHtml2(details.join(" \xB7 ") || "ok")}</div>`;
|
|
21515
21670
|
};
|
|
21516
21671
|
var defaultEvaluateResult = ({
|
|
21517
21672
|
cases,
|
|
@@ -21520,11 +21675,11 @@ var defaultEvaluateResult = ({
|
|
|
21520
21675
|
if (cases.length === 0) {
|
|
21521
21676
|
return renderEmptyState("evaluation");
|
|
21522
21677
|
}
|
|
21523
|
-
const caseRows = cases.map((entry) => `<tr class="rag-eval-row rag-eval-${entry.status}">` + `<td>${
|
|
21678
|
+
const caseRows = cases.map((entry) => `<tr class="rag-eval-row rag-eval-${entry.status}">` + `<td>${escapeHtml2(entry.caseId)}</td>` + `<td>${escapeHtml2(entry.mode)}</td>` + `<td>${escapeHtml2(entry.status)}</td>` + `<td>${entry.elapsedMs}</td>` + `<td>${entry.retrievedCount}</td>` + `<td>${entry.expectedCount}</td>` + `<td>${entry.matchedCount}</td>` + `<td>${entry.precision.toFixed(4)}</td>` + `<td>${entry.recall.toFixed(4)}</td>` + `<td>${entry.f1.toFixed(4)}</td>` + `<td>${escapeHtml2(entry.label ?? "n/a")}</td>` + `<td>${escapeHtml2(entry.missingIds.join(", ") || "none")}</td>` + `</tr>`).join("");
|
|
21524
21679
|
const passingRate = summary.totalCases > 0 ? (summary.passedCases / summary.totalCases * 100).toFixed(1) : "0.0";
|
|
21525
21680
|
return `<section class="rag-evaluation">` + `<h3>Evaluation</h3>` + `<p>${summary.totalCases} cases \xB7 ${summary.passedCases} pass \xB7 ${summary.partialCases} partial \xB7 ${summary.failedCases} fail \xB7 passing ${passingRate}%</p>` + `<table class="rag-eval-table"><thead><tr><th>Case</th><th>Mode</th><th>Status</th><th>ms</th><th>Retrieved</th><th>Expected</th><th>Matched</th><th>Precision</th><th>Recall</th><th>F1</th><th>Label</th><th>Missing</th></tr></thead><tbody>${caseRows}</tbody></table>` + `<dl class="rag-eval-summary"><div><dt>Average precision</dt><dd>${summary.averagePrecision.toFixed(4)}</dd></div><div><dt>Average recall</dt><dd>${summary.averageRecall.toFixed(4)}</dd></div><div><dt>Average F1</dt><dd>${summary.averageF1.toFixed(4)}</dd></div><div><dt>Average latency</dt><dd>${summary.averageLatencyMs.toFixed(1)}ms</dd></div></dl>` + `</section>`;
|
|
21526
21681
|
};
|
|
21527
|
-
var defaultError = (message) => `<div class="rag-error">${
|
|
21682
|
+
var defaultError = (message) => `<div class="rag-error">${escapeHtml2(message)}</div>`;
|
|
21528
21683
|
var defaultMaintenance = (input) => renderMaintenancePanel(input);
|
|
21529
21684
|
var resolveRAGWorkflowRenderers = (custom) => ({
|
|
21530
21685
|
adaptiveNativePlannerBenchmark: custom?.adaptiveNativePlannerBenchmark ?? defaultAdaptiveNativePlannerBenchmark,
|
|
@@ -21548,7 +21703,7 @@ var resolveRAGWorkflowRenderers = (custom) => ({
|
|
|
21548
21703
|
status: custom?.status ?? defaultStatus
|
|
21549
21704
|
});
|
|
21550
21705
|
|
|
21551
|
-
// src/
|
|
21706
|
+
// src/retrieval/context.ts
|
|
21552
21707
|
var getContextNumber3 = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
21553
21708
|
var getContextString3 = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
21554
21709
|
var formatMediaTimestamp3 = (value) => {
|
|
@@ -37649,5 +37804,5 @@ export {
|
|
|
37649
37804
|
addRAGEvaluationSuiteCase
|
|
37650
37805
|
};
|
|
37651
37806
|
|
|
37652
|
-
//# debugId=
|
|
37807
|
+
//# debugId=81C188D9E871FD2564756E2164756E21
|
|
37653
37808
|
//# sourceMappingURL=index.js.map
|