@absolutejs/absolute 0.19.0-beta.604 → 0.19.0-beta.605
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 +186 -6
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +190 -6
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +289 -36
- package/dist/ai/index.js.map +7 -7
- package/dist/ai/rag/quality.js +17 -6
- package/dist/ai/rag/quality.js.map +3 -3
- package/dist/ai/rag/ui.js +190 -6
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +185 -5
- package/dist/ai-client/react/ai/index.js +200 -6
- package/dist/ai-client/vue/ai/index.js +289 -97
- package/dist/angular/ai/index.js +186 -6
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/server.js +2 -2
- package/dist/angular/server.js.map +1 -1
- package/dist/build.js +2 -2
- package/dist/build.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/ai/index.js +201 -7
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ui.d.ts +1 -1
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/presentation.d.ts +7 -1
- package/dist/src/ai/rag/ui.d.ts +1 -1
- package/dist/src/react/ai/useRAG.d.ts +5 -0
- package/dist/src/react/ai/useRAGChunkPreview.d.ts +4 -0
- package/dist/src/react/ai/useRAGSources.d.ts +1 -0
- package/dist/src/svelte/ai/createRAG.d.ts +5 -0
- package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +4 -0
- package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
- package/dist/src/vue/ai/useRAG.d.ts +65 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +34 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +30 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
- package/dist/svelte/ai/index.js +247 -53
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +60 -0
- package/dist/vue/ai/index.js +253 -59
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
package/dist/ai/rag/ui.js
CHANGED
|
@@ -132,6 +132,11 @@ var buildContextLabel = (metadata) => {
|
|
|
132
132
|
if (speaker) {
|
|
133
133
|
return `Speaker ${speaker}`;
|
|
134
134
|
}
|
|
135
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
136
|
+
const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
137
|
+
if (sectionTitle) {
|
|
138
|
+
return `Section ${sectionTitle}`;
|
|
139
|
+
}
|
|
135
140
|
return;
|
|
136
141
|
};
|
|
137
142
|
var formatMediaTimestamp = (value) => {
|
|
@@ -181,6 +186,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
181
186
|
if (mediaStart) {
|
|
182
187
|
return `Timestamp ${mediaStart}`;
|
|
183
188
|
}
|
|
189
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
190
|
+
if (sectionPath.length > 0) {
|
|
191
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
192
|
+
}
|
|
184
193
|
return;
|
|
185
194
|
};
|
|
186
195
|
var formatTimestampLabel = (value) => {
|
|
@@ -230,8 +239,10 @@ var buildExcerpt = (text, maxLength = 160) => {
|
|
|
230
239
|
var buildGroundingReferenceEvidenceLabel = (reference) => [reference.label, reference.locatorLabel, reference.contextLabel].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
231
240
|
var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
232
241
|
reference.source ?? reference.title ?? reference.chunkId,
|
|
242
|
+
reference.locatorLabel,
|
|
243
|
+
reference.contextLabel,
|
|
233
244
|
reference.provenanceLabel
|
|
234
|
-
].filter((value) => Boolean(value && value.length > 0)).join(" \xB7 ");
|
|
245
|
+
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
235
246
|
var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
236
247
|
contextLabel: reference.contextLabel,
|
|
237
248
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
@@ -255,12 +266,12 @@ var buildRAGCitations = (sources) => {
|
|
|
255
266
|
continue;
|
|
256
267
|
unique.set(key, {
|
|
257
268
|
chunkId: source.chunkId,
|
|
258
|
-
contextLabel: buildContextLabel(source.metadata),
|
|
269
|
+
contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
|
|
259
270
|
key,
|
|
260
271
|
label: buildSourceLabel(source),
|
|
261
|
-
locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
|
|
272
|
+
locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
|
|
262
273
|
metadata: source.metadata,
|
|
263
|
-
provenanceLabel: buildProvenanceLabel(source.metadata),
|
|
274
|
+
provenanceLabel: source.labels?.provenanceLabel ?? buildProvenanceLabel(source.metadata),
|
|
264
275
|
score: source.score,
|
|
265
276
|
source: source.source,
|
|
266
277
|
text: source.text,
|
|
@@ -330,7 +341,7 @@ var buildRAGGroundingReferences = (sources) => {
|
|
|
330
341
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
331
342
|
return citations.map((citation) => ({
|
|
332
343
|
chunkId: citation.chunkId,
|
|
333
|
-
contextLabel: buildContextLabel(citation.metadata),
|
|
344
|
+
contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
|
|
334
345
|
excerpt: buildExcerpt(citation.text),
|
|
335
346
|
label: citation.label,
|
|
336
347
|
locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
|
|
@@ -832,6 +843,11 @@ var buildContextLabel2 = (metadata) => {
|
|
|
832
843
|
if (speaker) {
|
|
833
844
|
return `Speaker ${speaker}`;
|
|
834
845
|
}
|
|
846
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
847
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
848
|
+
if (sectionTitle) {
|
|
849
|
+
return `Section ${sectionTitle}`;
|
|
850
|
+
}
|
|
835
851
|
return;
|
|
836
852
|
};
|
|
837
853
|
var buildLocatorLabel2 = (metadata, source, title) => {
|
|
@@ -871,6 +887,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
871
887
|
if (mediaStart) {
|
|
872
888
|
return `Timestamp ${mediaStart}`;
|
|
873
889
|
}
|
|
890
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
891
|
+
if (sectionPath.length > 0) {
|
|
892
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
893
|
+
}
|
|
874
894
|
return;
|
|
875
895
|
};
|
|
876
896
|
var buildProvenanceLabel2 = (metadata) => {
|
|
@@ -916,6 +936,33 @@ var buildRAGSourceLabels = ({
|
|
|
916
936
|
provenanceLabel
|
|
917
937
|
};
|
|
918
938
|
};
|
|
939
|
+
var buildRAGChunkStructure = (metadata) => {
|
|
940
|
+
if (!metadata) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
944
|
+
const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" ? metadata.sectionKind : undefined;
|
|
945
|
+
const section = {
|
|
946
|
+
depth: getContextNumber2(metadata.sectionDepth),
|
|
947
|
+
kind: sectionKind,
|
|
948
|
+
path: sectionPath && sectionPath.length > 0 ? sectionPath : undefined,
|
|
949
|
+
title: getContextString2(metadata.sectionTitle)
|
|
950
|
+
};
|
|
951
|
+
const sequence = {
|
|
952
|
+
nextChunkId: getContextString2(metadata.nextChunkId),
|
|
953
|
+
previousChunkId: getContextString2(metadata.previousChunkId),
|
|
954
|
+
sectionChunkCount: getContextNumber2(metadata.sectionChunkCount),
|
|
955
|
+
sectionChunkId: getContextString2(metadata.sectionChunkId),
|
|
956
|
+
sectionChunkIndex: getContextNumber2(metadata.sectionChunkIndex)
|
|
957
|
+
};
|
|
958
|
+
if (!section.title && (!section.path || section.path.length === 0) && typeof section.depth !== "number" && !section.kind && !sequence.nextChunkId && !sequence.previousChunkId && typeof sequence.sectionChunkCount !== "number" && !sequence.sectionChunkId && typeof sequence.sectionChunkIndex !== "number") {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
return {
|
|
962
|
+
section: section.title || section.path && section.path.length > 0 || typeof section.depth === "number" || section.kind ? section : undefined,
|
|
963
|
+
sequence: sequence.nextChunkId || sequence.previousChunkId || typeof sequence.sectionChunkCount === "number" || sequence.sectionChunkId || typeof sequence.sectionChunkIndex === "number" ? sequence : undefined
|
|
964
|
+
};
|
|
965
|
+
};
|
|
919
966
|
var buildExcerpt2 = (text, maxLength = 160) => {
|
|
920
967
|
const normalized = text.replaceAll(/\s+/g, " ").trim();
|
|
921
968
|
if (normalized.length <= maxLength) {
|
|
@@ -923,6 +970,136 @@ var buildExcerpt2 = (text, maxLength = 160) => {
|
|
|
923
970
|
}
|
|
924
971
|
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
925
972
|
};
|
|
973
|
+
var buildRAGChunkGraph = (chunks) => {
|
|
974
|
+
const nodes = [];
|
|
975
|
+
const edges = [];
|
|
976
|
+
const edgeKeys = new Set;
|
|
977
|
+
const sections = new Map;
|
|
978
|
+
for (const chunk of chunks) {
|
|
979
|
+
const labels = chunk.labels ?? buildRAGSourceLabels({
|
|
980
|
+
metadata: chunk.metadata,
|
|
981
|
+
source: chunk.source,
|
|
982
|
+
title: chunk.title
|
|
983
|
+
});
|
|
984
|
+
const structure = chunk.structure ?? buildRAGChunkStructure(chunk.metadata);
|
|
985
|
+
nodes.push({
|
|
986
|
+
chunkId: chunk.chunkId,
|
|
987
|
+
contextLabel: labels?.contextLabel,
|
|
988
|
+
label: chunk.source ?? chunk.title ?? chunk.chunkId,
|
|
989
|
+
locatorLabel: labels?.locatorLabel,
|
|
990
|
+
provenanceLabel: labels?.provenanceLabel,
|
|
991
|
+
score: chunk.score,
|
|
992
|
+
source: chunk.source,
|
|
993
|
+
structure,
|
|
994
|
+
title: chunk.title
|
|
995
|
+
});
|
|
996
|
+
const previousChunkId = structure?.sequence?.previousChunkId;
|
|
997
|
+
if (previousChunkId) {
|
|
998
|
+
const key = `previous:${previousChunkId}:${chunk.chunkId}`;
|
|
999
|
+
if (!edgeKeys.has(key)) {
|
|
1000
|
+
edgeKeys.add(key);
|
|
1001
|
+
edges.push({
|
|
1002
|
+
fromChunkId: previousChunkId,
|
|
1003
|
+
relation: "previous",
|
|
1004
|
+
toChunkId: chunk.chunkId
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
const nextChunkId = structure?.sequence?.nextChunkId;
|
|
1009
|
+
if (nextChunkId) {
|
|
1010
|
+
const key = `next:${chunk.chunkId}:${nextChunkId}`;
|
|
1011
|
+
if (!edgeKeys.has(key)) {
|
|
1012
|
+
edgeKeys.add(key);
|
|
1013
|
+
edges.push({
|
|
1014
|
+
fromChunkId: chunk.chunkId,
|
|
1015
|
+
relation: "next",
|
|
1016
|
+
toChunkId: nextChunkId
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
const sectionId = structure?.sequence?.sectionChunkId;
|
|
1021
|
+
if (sectionId) {
|
|
1022
|
+
const existing = sections.get(sectionId);
|
|
1023
|
+
if (!existing) {
|
|
1024
|
+
sections.set(sectionId, {
|
|
1025
|
+
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1026
|
+
chunkIds: [chunk.chunkId],
|
|
1027
|
+
depth: structure.section?.depth,
|
|
1028
|
+
id: sectionId,
|
|
1029
|
+
kind: structure.section?.kind,
|
|
1030
|
+
path: structure.section?.path,
|
|
1031
|
+
title: structure.section?.title
|
|
1032
|
+
});
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
if (!existing.chunkIds.includes(chunk.chunkId)) {
|
|
1036
|
+
existing.chunkIds.push(chunk.chunkId);
|
|
1037
|
+
}
|
|
1038
|
+
existing.chunkCount = Math.max(existing.chunkCount, structure.sequence?.sectionChunkCount ?? existing.chunkCount);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
for (const section of sections.values()) {
|
|
1042
|
+
section.chunkIds.sort((left, right) => {
|
|
1043
|
+
const leftNode = nodes.find((node) => node.chunkId === left);
|
|
1044
|
+
const rightNode = nodes.find((node) => node.chunkId === right);
|
|
1045
|
+
const leftIndex = leftNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1046
|
+
const rightIndex = rightNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1047
|
+
if (leftIndex !== rightIndex) {
|
|
1048
|
+
return leftIndex - rightIndex;
|
|
1049
|
+
}
|
|
1050
|
+
return left.localeCompare(right);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
nodes.sort((left, right) => {
|
|
1054
|
+
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1055
|
+
const rightSection = right.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1056
|
+
if (leftSection !== rightSection) {
|
|
1057
|
+
return leftSection - rightSection;
|
|
1058
|
+
}
|
|
1059
|
+
const leftScore = left.score ?? Number.NEGATIVE_INFINITY;
|
|
1060
|
+
const rightScore = right.score ?? Number.NEGATIVE_INFINITY;
|
|
1061
|
+
if (leftScore !== rightScore) {
|
|
1062
|
+
return rightScore - leftScore;
|
|
1063
|
+
}
|
|
1064
|
+
return left.label.localeCompare(right.label);
|
|
1065
|
+
});
|
|
1066
|
+
return {
|
|
1067
|
+
edges,
|
|
1068
|
+
nodes,
|
|
1069
|
+
sections: [...sections.values()].sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
var buildRAGChunkPreviewGraph = (preview) => buildRAGChunkGraph(preview.chunks.map((chunk) => ({
|
|
1073
|
+
chunkId: chunk.chunkId,
|
|
1074
|
+
labels: chunk.labels,
|
|
1075
|
+
metadata: chunk.metadata,
|
|
1076
|
+
source: chunk.source ?? preview.document.source,
|
|
1077
|
+
structure: chunk.structure,
|
|
1078
|
+
title: chunk.title ?? preview.document.title
|
|
1079
|
+
})));
|
|
1080
|
+
var buildRAGChunkPreviewNavigation = (preview, activeChunkId) => buildRAGChunkGraphNavigation(buildRAGChunkPreviewGraph(preview), activeChunkId);
|
|
1081
|
+
var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
1082
|
+
if (graph.nodes.length === 0) {
|
|
1083
|
+
return {
|
|
1084
|
+
activeChunkId,
|
|
1085
|
+
sectionNodes: []
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
const activeNode = (activeChunkId ? graph.nodes.find((node) => node.chunkId === activeChunkId) : undefined) ?? graph.nodes[0];
|
|
1089
|
+
const resolvedActiveChunkId = activeNode?.chunkId;
|
|
1090
|
+
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1091
|
+
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1092
|
+
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1093
|
+
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1094
|
+
return {
|
|
1095
|
+
activeChunkId: resolvedActiveChunkId,
|
|
1096
|
+
activeNode,
|
|
1097
|
+
nextNode,
|
|
1098
|
+
previousNode,
|
|
1099
|
+
section,
|
|
1100
|
+
sectionNodes
|
|
1101
|
+
};
|
|
1102
|
+
};
|
|
926
1103
|
var buildRAGRetrievedState = (messages) => {
|
|
927
1104
|
const message = getLatestRetrievedMessage(messages);
|
|
928
1105
|
if (!message) {
|
|
@@ -964,6 +1141,7 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
964
1141
|
label: group.label,
|
|
965
1142
|
locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
|
|
966
1143
|
provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
|
|
1144
|
+
structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
|
|
967
1145
|
source: group.source,
|
|
968
1146
|
title: group.title
|
|
969
1147
|
};
|
|
@@ -1092,6 +1270,7 @@ var buildSourceGroup = (source, key) => ({
|
|
|
1092
1270
|
source: source.source,
|
|
1093
1271
|
title: source.title
|
|
1094
1272
|
}),
|
|
1273
|
+
structure: source.structure ?? buildRAGChunkStructure(source.metadata),
|
|
1095
1274
|
source: source.source,
|
|
1096
1275
|
title: source.title
|
|
1097
1276
|
});
|
|
@@ -1110,6 +1289,7 @@ var updateSourceGroup = (groups, source) => {
|
|
|
1110
1289
|
source: source.source,
|
|
1111
1290
|
title: source.title
|
|
1112
1291
|
});
|
|
1292
|
+
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
1113
1293
|
existing.source = source.source;
|
|
1114
1294
|
existing.title = source.title;
|
|
1115
1295
|
} else {
|
|
@@ -1769,6 +1949,10 @@ export {
|
|
|
1769
1949
|
buildRAGComparisonTraceDiffRows,
|
|
1770
1950
|
buildRAGCitations,
|
|
1771
1951
|
buildRAGCitationReferenceMap,
|
|
1952
|
+
buildRAGChunkPreviewNavigation,
|
|
1953
|
+
buildRAGChunkPreviewGraph,
|
|
1954
|
+
buildRAGChunkGraphNavigation,
|
|
1955
|
+
buildRAGChunkGraph,
|
|
1772
1956
|
buildRAGAnswerWorkflowState,
|
|
1773
1957
|
buildRAGAnswerGroundingHistoryRows,
|
|
1774
1958
|
buildRAGAnswerGroundingHistoryPresentation,
|
|
@@ -1779,5 +1963,5 @@ export {
|
|
|
1779
1963
|
buildRAGAdminActionPresentation
|
|
1780
1964
|
};
|
|
1781
1965
|
|
|
1782
|
-
//# debugId=
|
|
1966
|
+
//# debugId=45AD43905031CDB064756E2164756E21
|
|
1783
1967
|
//# sourceMappingURL=ui.js.map
|