@absolutejs/absolute 0.19.0-beta.605 → 0.19.0-beta.607
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 +112 -1
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +113 -1
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +153 -4
- package/dist/ai/index.js.map +6 -6
- package/dist/ai/rag/quality.js +60 -1
- package/dist/ai/rag/quality.js.map +3 -3
- package/dist/ai/rag/ui.js +113 -1
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +111 -0
- package/dist/ai-client/react/ai/index.js +141 -7
- package/dist/ai-client/vue/ai/index.js +135 -1
- package/dist/angular/ai/index.js +112 -1
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/react/ai/index.js +142 -8
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ui.d.ts +1 -1
- package/dist/src/ai/rag/grounding.d.ts +2 -1
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/presentation.d.ts +2 -2
- package/dist/src/ai/rag/ui.d.ts +1 -1
- 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 +149 -3
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +20 -1
- package/dist/vue/ai/index.js +136 -2
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
package/dist/ai/client/ui.js
CHANGED
|
@@ -243,6 +243,13 @@ var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
|
243
243
|
reference.contextLabel,
|
|
244
244
|
reference.provenanceLabel
|
|
245
245
|
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
246
|
+
var buildGroundingSectionKey = (reference) => reference.contextLabel ?? reference.locatorLabel ?? reference.label ?? reference.source ?? reference.chunkId;
|
|
247
|
+
var buildGroundingSectionSummaryLine = (reference) => [
|
|
248
|
+
reference.source ?? reference.title ?? reference.chunkId,
|
|
249
|
+
reference.locatorLabel,
|
|
250
|
+
reference.contextLabel,
|
|
251
|
+
reference.provenanceLabel
|
|
252
|
+
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
246
253
|
var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
247
254
|
contextLabel: reference.contextLabel,
|
|
248
255
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
@@ -333,9 +340,61 @@ var buildRAGGroundedAnswer = (content, sources) => {
|
|
|
333
340
|
hasCitations,
|
|
334
341
|
parts,
|
|
335
342
|
references,
|
|
343
|
+
sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
|
|
336
344
|
ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
|
|
337
345
|
};
|
|
338
346
|
};
|
|
347
|
+
var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
348
|
+
const groups = new Map;
|
|
349
|
+
for (const reference of references) {
|
|
350
|
+
const key = buildGroundingSectionKey(reference);
|
|
351
|
+
const existing = groups.get(key);
|
|
352
|
+
if (!existing) {
|
|
353
|
+
groups.set(key, {
|
|
354
|
+
chunkIds: [reference.chunkId],
|
|
355
|
+
contextLabel: reference.contextLabel,
|
|
356
|
+
count: 1,
|
|
357
|
+
key,
|
|
358
|
+
label: key,
|
|
359
|
+
locatorLabel: reference.locatorLabel,
|
|
360
|
+
provenanceLabel: reference.provenanceLabel,
|
|
361
|
+
referenceNumbers: [reference.number],
|
|
362
|
+
references: [reference],
|
|
363
|
+
summary: buildGroundingSectionSummaryLine(reference) || reference.label || reference.chunkId
|
|
364
|
+
});
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
existing.count += 1;
|
|
368
|
+
if (!existing.chunkIds.includes(reference.chunkId)) {
|
|
369
|
+
existing.chunkIds.push(reference.chunkId);
|
|
370
|
+
}
|
|
371
|
+
if (!existing.referenceNumbers.includes(reference.number)) {
|
|
372
|
+
existing.referenceNumbers.push(reference.number);
|
|
373
|
+
}
|
|
374
|
+
existing.references.push(reference);
|
|
375
|
+
if (!existing.contextLabel && reference.contextLabel) {
|
|
376
|
+
existing.contextLabel = reference.contextLabel;
|
|
377
|
+
}
|
|
378
|
+
if (!existing.locatorLabel && reference.locatorLabel) {
|
|
379
|
+
existing.locatorLabel = reference.locatorLabel;
|
|
380
|
+
}
|
|
381
|
+
if (!existing.provenanceLabel && reference.provenanceLabel) {
|
|
382
|
+
existing.provenanceLabel = reference.provenanceLabel;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return [...groups.values()].map((group) => ({
|
|
386
|
+
...group,
|
|
387
|
+
referenceNumbers: [...group.referenceNumbers].sort((left, right) => left - right),
|
|
388
|
+
references: group.references.slice().sort((left, right) => left.number - right.number)
|
|
389
|
+
})).sort((left, right) => {
|
|
390
|
+
const leftFirst = left.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
|
|
391
|
+
const rightFirst = right.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
|
|
392
|
+
if (leftFirst !== rightFirst) {
|
|
393
|
+
return leftFirst - rightFirst;
|
|
394
|
+
}
|
|
395
|
+
return left.label.localeCompare(right.label);
|
|
396
|
+
});
|
|
397
|
+
};
|
|
339
398
|
var buildRAGGroundingReferences = (sources) => {
|
|
340
399
|
const citations = buildRAGCitations(sources);
|
|
341
400
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
@@ -1022,11 +1081,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1022
1081
|
const existing = sections.get(sectionId);
|
|
1023
1082
|
if (!existing) {
|
|
1024
1083
|
sections.set(sectionId, {
|
|
1084
|
+
childSectionIds: [],
|
|
1025
1085
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1026
1086
|
chunkIds: [chunk.chunkId],
|
|
1027
1087
|
depth: structure.section?.depth,
|
|
1028
1088
|
id: sectionId,
|
|
1029
1089
|
kind: structure.section?.kind,
|
|
1090
|
+
leadChunkId: chunk.chunkId,
|
|
1030
1091
|
path: structure.section?.path,
|
|
1031
1092
|
title: structure.section?.title
|
|
1032
1093
|
});
|
|
@@ -1049,6 +1110,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1049
1110
|
}
|
|
1050
1111
|
return left.localeCompare(right);
|
|
1051
1112
|
});
|
|
1113
|
+
section.leadChunkId = section.chunkIds[0];
|
|
1114
|
+
}
|
|
1115
|
+
const sectionPathIndex = new Map;
|
|
1116
|
+
for (const section of sections.values()) {
|
|
1117
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1118
|
+
if (path && path.length > 0) {
|
|
1119
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
for (const section of sections.values()) {
|
|
1123
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1124
|
+
if (!path || path.length < 2) {
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
1128
|
+
if (!parent || parent.id === section.id) {
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
section.parentSectionId = parent.id;
|
|
1132
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
1133
|
+
parent.childSectionIds.push(section.id);
|
|
1134
|
+
}
|
|
1135
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
1136
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
1137
|
+
if (!edgeKeys.has(parentKey)) {
|
|
1138
|
+
edgeKeys.add(parentKey);
|
|
1139
|
+
edges.push({
|
|
1140
|
+
fromChunkId: section.leadChunkId,
|
|
1141
|
+
relation: "section_parent",
|
|
1142
|
+
toChunkId: parent.leadChunkId
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
1146
|
+
if (!edgeKeys.has(childKey)) {
|
|
1147
|
+
edgeKeys.add(childKey);
|
|
1148
|
+
edges.push({
|
|
1149
|
+
fromChunkId: parent.leadChunkId,
|
|
1150
|
+
relation: "section_child",
|
|
1151
|
+
toChunkId: section.leadChunkId
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1052
1155
|
}
|
|
1053
1156
|
nodes.sort((left, right) => {
|
|
1054
1157
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1082,6 +1185,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1082
1185
|
if (graph.nodes.length === 0) {
|
|
1083
1186
|
return {
|
|
1084
1187
|
activeChunkId,
|
|
1188
|
+
childSections: [],
|
|
1189
|
+
siblingSections: [],
|
|
1085
1190
|
sectionNodes: []
|
|
1086
1191
|
};
|
|
1087
1192
|
}
|
|
@@ -1090,13 +1195,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1090
1195
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1091
1196
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1092
1197
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1198
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
1199
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
1200
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
1093
1201
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1094
1202
|
return {
|
|
1095
1203
|
activeChunkId: resolvedActiveChunkId,
|
|
1096
1204
|
activeNode,
|
|
1205
|
+
childSections,
|
|
1097
1206
|
nextNode,
|
|
1207
|
+
parentSection,
|
|
1098
1208
|
previousNode,
|
|
1099
1209
|
section,
|
|
1210
|
+
siblingSections,
|
|
1100
1211
|
sectionNodes
|
|
1101
1212
|
};
|
|
1102
1213
|
};
|
|
@@ -1923,6 +2034,7 @@ export {
|
|
|
1923
2034
|
buildRAGSourceSummaries,
|
|
1924
2035
|
buildRAGSourceGroups,
|
|
1925
2036
|
buildRAGGroundingReferences,
|
|
2037
|
+
buildRAGGroundedAnswerSectionSummaries,
|
|
1926
2038
|
buildRAGGroundedAnswer,
|
|
1927
2039
|
buildRAGCitationReferenceMap,
|
|
1928
2040
|
buildRAGChunkPreviewNavigation,
|
|
@@ -1932,5 +2044,5 @@ export {
|
|
|
1932
2044
|
buildRAGAnswerWorkflowState
|
|
1933
2045
|
};
|
|
1934
2046
|
|
|
1935
|
-
//# debugId=
|
|
2047
|
+
//# debugId=2E81BE875BD0169964756E2164756E21
|
|
1936
2048
|
//# sourceMappingURL=ui.js.map
|