@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/angular/ai/index.js
CHANGED
|
@@ -1021,6 +1021,13 @@ var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
|
1021
1021
|
reference.contextLabel,
|
|
1022
1022
|
reference.provenanceLabel
|
|
1023
1023
|
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
1024
|
+
var buildGroundingSectionKey = (reference) => reference.contextLabel ?? reference.locatorLabel ?? reference.label ?? reference.source ?? reference.chunkId;
|
|
1025
|
+
var buildGroundingSectionSummaryLine = (reference) => [
|
|
1026
|
+
reference.source ?? reference.title ?? reference.chunkId,
|
|
1027
|
+
reference.locatorLabel,
|
|
1028
|
+
reference.contextLabel,
|
|
1029
|
+
reference.provenanceLabel
|
|
1030
|
+
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
1024
1031
|
var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
1025
1032
|
contextLabel: reference.contextLabel,
|
|
1026
1033
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
@@ -1111,9 +1118,61 @@ var buildRAGGroundedAnswer = (content, sources) => {
|
|
|
1111
1118
|
hasCitations,
|
|
1112
1119
|
parts,
|
|
1113
1120
|
references,
|
|
1121
|
+
sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
|
|
1114
1122
|
ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
|
|
1115
1123
|
};
|
|
1116
1124
|
};
|
|
1125
|
+
var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
1126
|
+
const groups = new Map;
|
|
1127
|
+
for (const reference of references) {
|
|
1128
|
+
const key = buildGroundingSectionKey(reference);
|
|
1129
|
+
const existing = groups.get(key);
|
|
1130
|
+
if (!existing) {
|
|
1131
|
+
groups.set(key, {
|
|
1132
|
+
chunkIds: [reference.chunkId],
|
|
1133
|
+
contextLabel: reference.contextLabel,
|
|
1134
|
+
count: 1,
|
|
1135
|
+
key,
|
|
1136
|
+
label: key,
|
|
1137
|
+
locatorLabel: reference.locatorLabel,
|
|
1138
|
+
provenanceLabel: reference.provenanceLabel,
|
|
1139
|
+
referenceNumbers: [reference.number],
|
|
1140
|
+
references: [reference],
|
|
1141
|
+
summary: buildGroundingSectionSummaryLine(reference) || reference.label || reference.chunkId
|
|
1142
|
+
});
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
existing.count += 1;
|
|
1146
|
+
if (!existing.chunkIds.includes(reference.chunkId)) {
|
|
1147
|
+
existing.chunkIds.push(reference.chunkId);
|
|
1148
|
+
}
|
|
1149
|
+
if (!existing.referenceNumbers.includes(reference.number)) {
|
|
1150
|
+
existing.referenceNumbers.push(reference.number);
|
|
1151
|
+
}
|
|
1152
|
+
existing.references.push(reference);
|
|
1153
|
+
if (!existing.contextLabel && reference.contextLabel) {
|
|
1154
|
+
existing.contextLabel = reference.contextLabel;
|
|
1155
|
+
}
|
|
1156
|
+
if (!existing.locatorLabel && reference.locatorLabel) {
|
|
1157
|
+
existing.locatorLabel = reference.locatorLabel;
|
|
1158
|
+
}
|
|
1159
|
+
if (!existing.provenanceLabel && reference.provenanceLabel) {
|
|
1160
|
+
existing.provenanceLabel = reference.provenanceLabel;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return [...groups.values()].map((group) => ({
|
|
1164
|
+
...group,
|
|
1165
|
+
referenceNumbers: [...group.referenceNumbers].sort((left, right) => left - right),
|
|
1166
|
+
references: group.references.slice().sort((left, right) => left.number - right.number)
|
|
1167
|
+
})).sort((left, right) => {
|
|
1168
|
+
const leftFirst = left.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
|
|
1169
|
+
const rightFirst = right.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
|
|
1170
|
+
if (leftFirst !== rightFirst) {
|
|
1171
|
+
return leftFirst - rightFirst;
|
|
1172
|
+
}
|
|
1173
|
+
return left.label.localeCompare(right.label);
|
|
1174
|
+
});
|
|
1175
|
+
};
|
|
1117
1176
|
var buildRAGGroundingReferences = (sources) => {
|
|
1118
1177
|
const citations = buildRAGCitations(sources);
|
|
1119
1178
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
@@ -1800,11 +1859,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1800
1859
|
const existing = sections.get(sectionId);
|
|
1801
1860
|
if (!existing) {
|
|
1802
1861
|
sections.set(sectionId, {
|
|
1862
|
+
childSectionIds: [],
|
|
1803
1863
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1804
1864
|
chunkIds: [chunk.chunkId],
|
|
1805
1865
|
depth: structure.section?.depth,
|
|
1806
1866
|
id: sectionId,
|
|
1807
1867
|
kind: structure.section?.kind,
|
|
1868
|
+
leadChunkId: chunk.chunkId,
|
|
1808
1869
|
path: structure.section?.path,
|
|
1809
1870
|
title: structure.section?.title
|
|
1810
1871
|
});
|
|
@@ -1827,6 +1888,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1827
1888
|
}
|
|
1828
1889
|
return left.localeCompare(right);
|
|
1829
1890
|
});
|
|
1891
|
+
section.leadChunkId = section.chunkIds[0];
|
|
1892
|
+
}
|
|
1893
|
+
const sectionPathIndex = new Map;
|
|
1894
|
+
for (const section of sections.values()) {
|
|
1895
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1896
|
+
if (path && path.length > 0) {
|
|
1897
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
for (const section of sections.values()) {
|
|
1901
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1902
|
+
if (!path || path.length < 2) {
|
|
1903
|
+
continue;
|
|
1904
|
+
}
|
|
1905
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
1906
|
+
if (!parent || parent.id === section.id) {
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
section.parentSectionId = parent.id;
|
|
1910
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
1911
|
+
parent.childSectionIds.push(section.id);
|
|
1912
|
+
}
|
|
1913
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
1914
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
1915
|
+
if (!edgeKeys.has(parentKey)) {
|
|
1916
|
+
edgeKeys.add(parentKey);
|
|
1917
|
+
edges.push({
|
|
1918
|
+
fromChunkId: section.leadChunkId,
|
|
1919
|
+
relation: "section_parent",
|
|
1920
|
+
toChunkId: parent.leadChunkId
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
1924
|
+
if (!edgeKeys.has(childKey)) {
|
|
1925
|
+
edgeKeys.add(childKey);
|
|
1926
|
+
edges.push({
|
|
1927
|
+
fromChunkId: parent.leadChunkId,
|
|
1928
|
+
relation: "section_child",
|
|
1929
|
+
toChunkId: section.leadChunkId
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1830
1933
|
}
|
|
1831
1934
|
nodes.sort((left, right) => {
|
|
1832
1935
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1860,6 +1963,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1860
1963
|
if (graph.nodes.length === 0) {
|
|
1861
1964
|
return {
|
|
1862
1965
|
activeChunkId,
|
|
1966
|
+
childSections: [],
|
|
1967
|
+
siblingSections: [],
|
|
1863
1968
|
sectionNodes: []
|
|
1864
1969
|
};
|
|
1865
1970
|
}
|
|
@@ -1868,13 +1973,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1868
1973
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1869
1974
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1870
1975
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1976
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
1977
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
1978
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
1871
1979
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1872
1980
|
return {
|
|
1873
1981
|
activeChunkId: resolvedActiveChunkId,
|
|
1874
1982
|
activeNode,
|
|
1983
|
+
childSections,
|
|
1875
1984
|
nextNode,
|
|
1985
|
+
parentSection,
|
|
1876
1986
|
previousNode,
|
|
1877
1987
|
section,
|
|
1988
|
+
siblingSections,
|
|
1878
1989
|
sectionNodes
|
|
1879
1990
|
};
|
|
1880
1991
|
};
|
|
@@ -4082,5 +4193,5 @@ export {
|
|
|
4082
4193
|
AIStreamService
|
|
4083
4194
|
};
|
|
4084
4195
|
|
|
4085
|
-
//# debugId=
|
|
4196
|
+
//# debugId=2C3A632BB772C68C64756E2164756E21
|
|
4086
4197
|
//# sourceMappingURL=index.js.map
|