@absolutejs/absolute 0.19.0-beta.605 → 0.19.0-beta.606
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/client/index.js +53 -1
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +53 -1
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +94 -4
- package/dist/ai/index.js.map +6 -6
- package/dist/ai/rag/quality.js.map +2 -2
- package/dist/ai/rag/ui.js +53 -1
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +52 -0
- package/dist/ai-client/react/ai/index.js +82 -7
- package/dist/ai-client/vue/ai/index.js +76 -1
- package/dist/angular/ai/index.js +53 -1
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/react/ai/index.js +83 -8
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/react/ai/useRAG.d.ts +4 -0
- package/dist/src/react/ai/useRAGChunkPreview.d.ts +3 -0
- package/dist/src/react/ai/useRAGSources.d.ts +1 -0
- package/dist/src/svelte/ai/createRAG.d.ts +4 -0
- package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +3 -0
- package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
- package/dist/src/vue/ai/useRAG.d.ts +4 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +3 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
- package/dist/svelte/ai/index.js +90 -3
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +7 -1
- package/dist/vue/ai/index.js +77 -2
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -4204,11 +4204,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
4204
4204
|
const existing = sections.get(sectionId);
|
|
4205
4205
|
if (!existing) {
|
|
4206
4206
|
sections.set(sectionId, {
|
|
4207
|
+
childSectionIds: [],
|
|
4207
4208
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
4208
4209
|
chunkIds: [chunk.chunkId],
|
|
4209
4210
|
depth: structure.section?.depth,
|
|
4210
4211
|
id: sectionId,
|
|
4211
4212
|
kind: structure.section?.kind,
|
|
4213
|
+
leadChunkId: chunk.chunkId,
|
|
4212
4214
|
path: structure.section?.path,
|
|
4213
4215
|
title: structure.section?.title
|
|
4214
4216
|
});
|
|
@@ -4231,6 +4233,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
4231
4233
|
}
|
|
4232
4234
|
return left.localeCompare(right);
|
|
4233
4235
|
});
|
|
4236
|
+
section.leadChunkId = section.chunkIds[0];
|
|
4237
|
+
}
|
|
4238
|
+
const sectionPathIndex = new Map;
|
|
4239
|
+
for (const section of sections.values()) {
|
|
4240
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
4241
|
+
if (path && path.length > 0) {
|
|
4242
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
for (const section of sections.values()) {
|
|
4246
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
4247
|
+
if (!path || path.length < 2) {
|
|
4248
|
+
continue;
|
|
4249
|
+
}
|
|
4250
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
4251
|
+
if (!parent || parent.id === section.id) {
|
|
4252
|
+
continue;
|
|
4253
|
+
}
|
|
4254
|
+
section.parentSectionId = parent.id;
|
|
4255
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
4256
|
+
parent.childSectionIds.push(section.id);
|
|
4257
|
+
}
|
|
4258
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
4259
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
4260
|
+
if (!edgeKeys.has(parentKey)) {
|
|
4261
|
+
edgeKeys.add(parentKey);
|
|
4262
|
+
edges.push({
|
|
4263
|
+
fromChunkId: section.leadChunkId,
|
|
4264
|
+
relation: "section_parent",
|
|
4265
|
+
toChunkId: parent.leadChunkId
|
|
4266
|
+
});
|
|
4267
|
+
}
|
|
4268
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
4269
|
+
if (!edgeKeys.has(childKey)) {
|
|
4270
|
+
edgeKeys.add(childKey);
|
|
4271
|
+
edges.push({
|
|
4272
|
+
fromChunkId: parent.leadChunkId,
|
|
4273
|
+
relation: "section_child",
|
|
4274
|
+
toChunkId: section.leadChunkId
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4234
4278
|
}
|
|
4235
4279
|
nodes.sort((left, right) => {
|
|
4236
4280
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -4264,6 +4308,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
4264
4308
|
if (graph.nodes.length === 0) {
|
|
4265
4309
|
return {
|
|
4266
4310
|
activeChunkId,
|
|
4311
|
+
childSections: [],
|
|
4312
|
+
siblingSections: [],
|
|
4267
4313
|
sectionNodes: []
|
|
4268
4314
|
};
|
|
4269
4315
|
}
|
|
@@ -4272,13 +4318,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
4272
4318
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
4273
4319
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
4274
4320
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
4321
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
4322
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
4323
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
4275
4324
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
4276
4325
|
return {
|
|
4277
4326
|
activeChunkId: resolvedActiveChunkId,
|
|
4278
4327
|
activeNode,
|
|
4328
|
+
childSections,
|
|
4279
4329
|
nextNode,
|
|
4330
|
+
parentSection,
|
|
4280
4331
|
previousNode,
|
|
4281
4332
|
section,
|
|
4333
|
+
siblingSections,
|
|
4282
4334
|
sectionNodes
|
|
4283
4335
|
};
|
|
4284
4336
|
};
|
|
@@ -10200,6 +10252,10 @@ var renderChunkStructure = (structure) => {
|
|
|
10200
10252
|
].filter((row) => row.length > 0);
|
|
10201
10253
|
return rows.length > 0 ? `<ul class="rag-chunk-structure">${rows.join("")}</ul>` : "";
|
|
10202
10254
|
};
|
|
10255
|
+
var renderSectionJumpList = (label, items) => {
|
|
10256
|
+
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("");
|
|
10257
|
+
return rows ? `<ul class="rag-chunk-structure">${rows}</ul>` : "";
|
|
10258
|
+
};
|
|
10203
10259
|
var renderEmptyState = (kind) => {
|
|
10204
10260
|
switch (kind) {
|
|
10205
10261
|
case "documents":
|
|
@@ -10239,17 +10295,43 @@ var defaultStatus = ({
|
|
|
10239
10295
|
}
|
|
10240
10296
|
return `<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>${renderCapabilityList(capabilities)}`;
|
|
10241
10297
|
};
|
|
10242
|
-
var defaultSearchResultItem = (source, index) =>
|
|
10298
|
+
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>";
|
|
10243
10299
|
var defaultSearchResults = ({
|
|
10244
10300
|
query,
|
|
10245
10301
|
results,
|
|
10246
10302
|
trace
|
|
10247
|
-
}) => results.length === 0 ? renderEmptyState("searchResults") :
|
|
10303
|
+
}) => results.length === 0 ? renderEmptyState("searchResults") : (() => {
|
|
10304
|
+
const graph = buildRAGChunkGraph(results);
|
|
10305
|
+
const availableChunkIds = new Set(results.map((result) => result.chunkId));
|
|
10306
|
+
return `<section class="rag-search-results">` + `<p class="rag-search-summary">${results.length} results for ${escapeHtml2(query)}</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>` : "") + `${results.map((result, index) => {
|
|
10307
|
+
const navigation = buildRAGChunkGraphNavigation(graph, result.chunkId);
|
|
10308
|
+
const sectionJumps = [
|
|
10309
|
+
navigation.parentSection?.leadChunkId ? renderSectionJumpList("Parent section", [
|
|
10310
|
+
{
|
|
10311
|
+
href: availableChunkIds.has(navigation.parentSection.leadChunkId) ? `#rag-search-result-${navigation.parentSection.leadChunkId}` : undefined,
|
|
10312
|
+
label: navigation.parentSection.title ?? navigation.parentSection.path?.join(" > ") ?? navigation.parentSection.id
|
|
10313
|
+
}
|
|
10314
|
+
]) : "",
|
|
10315
|
+
navigation.siblingSections.length > 0 ? renderSectionJumpList("Sibling section", navigation.siblingSections.map((section) => ({
|
|
10316
|
+
active: section.id === navigation.section?.id,
|
|
10317
|
+
href: section.leadChunkId && availableChunkIds.has(section.leadChunkId) ? `#rag-search-result-${section.leadChunkId}` : undefined,
|
|
10318
|
+
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
10319
|
+
}))) : "",
|
|
10320
|
+
navigation.childSections.length > 0 ? renderSectionJumpList("Child section", navigation.childSections.map((section) => ({
|
|
10321
|
+
href: section.leadChunkId && availableChunkIds.has(section.leadChunkId) ? `#rag-search-result-${section.leadChunkId}` : undefined,
|
|
10322
|
+
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
10323
|
+
}))) : ""
|
|
10324
|
+
].join("");
|
|
10325
|
+
return defaultSearchResultItem(result, index, sectionJumps);
|
|
10326
|
+
}).join("")}</section>`;
|
|
10327
|
+
})();
|
|
10248
10328
|
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>";
|
|
10249
10329
|
var defaultDocuments = ({
|
|
10250
10330
|
documents
|
|
10251
10331
|
}) => documents.length === 0 ? renderEmptyState("documents") : `<section class="rag-documents">${documents.map((document, index) => defaultDocumentItem(document, index)).join("")}</section>`;
|
|
10252
10332
|
var defaultChunkPreview = (input) => {
|
|
10333
|
+
const graph = buildRAGChunkPreviewGraph(input);
|
|
10334
|
+
const navigation = buildRAGChunkGraphNavigation(graph);
|
|
10253
10335
|
const groups = input.chunks.reduce((acc, chunk) => {
|
|
10254
10336
|
const metadata = chunk.metadata ?? {};
|
|
10255
10337
|
const kind = typeof metadata.sourceNativeKind === "string" ? metadata.sourceNativeKind : "document_chunk";
|
|
@@ -10272,7 +10354,15 @@ var defaultChunkPreview = (input) => {
|
|
|
10272
10354
|
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) + `<pre>${escapeHtml2(chunk.text)}</pre>` + "</article>").join("");
|
|
10273
10355
|
return `<section class="rag-chunk-group"><h4>${escapeHtml2(group.title)}</h4>${chunkHtml}</section>`;
|
|
10274
10356
|
}).join("");
|
|
10275
|
-
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) +
|
|
10357
|
+
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", [
|
|
10358
|
+
{
|
|
10359
|
+
label: navigation.parentSection.title ?? navigation.parentSection.path?.join(" > ") ?? navigation.parentSection.id
|
|
10360
|
+
}
|
|
10361
|
+
]) : "") + (navigation.siblingSections.length > 0 ? renderSectionJumpList("Sibling section", navigation.siblingSections.map((section) => ({
|
|
10362
|
+
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
10363
|
+
}))) : "") + (navigation.childSections.length > 0 ? renderSectionJumpList("Child section", navigation.childSections.map((section) => ({
|
|
10364
|
+
label: section.title ?? section.path?.join(" > ") ?? section.id
|
|
10365
|
+
}))) : "") + `<article class="rag-chunk-normalized">` + `<h4>Normalized text</h4>` + `<pre>${escapeHtml2(input.normalizedText)}</pre>` + `</article>${groupHtml}</section>`;
|
|
10276
10366
|
};
|
|
10277
10367
|
var defaultMutationResult = (input) => {
|
|
10278
10368
|
if (!input.ok) {
|
|
@@ -21450,5 +21540,5 @@ export {
|
|
|
21450
21540
|
aiChat
|
|
21451
21541
|
};
|
|
21452
21542
|
|
|
21453
|
-
//# debugId=
|
|
21543
|
+
//# debugId=A318A9B225410C8664756E2164756E21
|
|
21454
21544
|
//# sourceMappingURL=index.js.map
|