@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/angular/ai/index.js
CHANGED
|
@@ -910,6 +910,11 @@ var buildContextLabel = (metadata) => {
|
|
|
910
910
|
if (speaker) {
|
|
911
911
|
return `Speaker ${speaker}`;
|
|
912
912
|
}
|
|
913
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
914
|
+
const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
915
|
+
if (sectionTitle) {
|
|
916
|
+
return `Section ${sectionTitle}`;
|
|
917
|
+
}
|
|
913
918
|
return;
|
|
914
919
|
};
|
|
915
920
|
var formatMediaTimestamp = (value) => {
|
|
@@ -959,6 +964,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
959
964
|
if (mediaStart) {
|
|
960
965
|
return `Timestamp ${mediaStart}`;
|
|
961
966
|
}
|
|
967
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
968
|
+
if (sectionPath.length > 0) {
|
|
969
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
970
|
+
}
|
|
962
971
|
return;
|
|
963
972
|
};
|
|
964
973
|
var formatTimestampLabel = (value) => {
|
|
@@ -1008,8 +1017,10 @@ var buildExcerpt = (text, maxLength = 160) => {
|
|
|
1008
1017
|
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 ");
|
|
1009
1018
|
var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
1010
1019
|
reference.source ?? reference.title ?? reference.chunkId,
|
|
1020
|
+
reference.locatorLabel,
|
|
1021
|
+
reference.contextLabel,
|
|
1011
1022
|
reference.provenanceLabel
|
|
1012
|
-
].filter((value) => Boolean(value && value.length > 0)).join(" \xB7 ");
|
|
1023
|
+
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
1013
1024
|
var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
1014
1025
|
contextLabel: reference.contextLabel,
|
|
1015
1026
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
@@ -1033,12 +1044,12 @@ var buildRAGCitations = (sources) => {
|
|
|
1033
1044
|
continue;
|
|
1034
1045
|
unique.set(key, {
|
|
1035
1046
|
chunkId: source.chunkId,
|
|
1036
|
-
contextLabel: buildContextLabel(source.metadata),
|
|
1047
|
+
contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
|
|
1037
1048
|
key,
|
|
1038
1049
|
label: buildSourceLabel(source),
|
|
1039
|
-
locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
|
|
1050
|
+
locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
|
|
1040
1051
|
metadata: source.metadata,
|
|
1041
|
-
provenanceLabel: buildProvenanceLabel(source.metadata),
|
|
1052
|
+
provenanceLabel: source.labels?.provenanceLabel ?? buildProvenanceLabel(source.metadata),
|
|
1042
1053
|
score: source.score,
|
|
1043
1054
|
source: source.source,
|
|
1044
1055
|
text: source.text,
|
|
@@ -1108,7 +1119,7 @@ var buildRAGGroundingReferences = (sources) => {
|
|
|
1108
1119
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
1109
1120
|
return citations.map((citation) => ({
|
|
1110
1121
|
chunkId: citation.chunkId,
|
|
1111
|
-
contextLabel: buildContextLabel(citation.metadata),
|
|
1122
|
+
contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
|
|
1112
1123
|
excerpt: buildExcerpt(citation.text),
|
|
1113
1124
|
label: citation.label,
|
|
1114
1125
|
locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
|
|
@@ -1610,6 +1621,11 @@ var buildContextLabel2 = (metadata) => {
|
|
|
1610
1621
|
if (speaker) {
|
|
1611
1622
|
return `Speaker ${speaker}`;
|
|
1612
1623
|
}
|
|
1624
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
1625
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
1626
|
+
if (sectionTitle) {
|
|
1627
|
+
return `Section ${sectionTitle}`;
|
|
1628
|
+
}
|
|
1613
1629
|
return;
|
|
1614
1630
|
};
|
|
1615
1631
|
var buildLocatorLabel2 = (metadata, source, title) => {
|
|
@@ -1649,6 +1665,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
1649
1665
|
if (mediaStart) {
|
|
1650
1666
|
return `Timestamp ${mediaStart}`;
|
|
1651
1667
|
}
|
|
1668
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
1669
|
+
if (sectionPath.length > 0) {
|
|
1670
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
1671
|
+
}
|
|
1652
1672
|
return;
|
|
1653
1673
|
};
|
|
1654
1674
|
var buildProvenanceLabel2 = (metadata) => {
|
|
@@ -1694,6 +1714,33 @@ var buildRAGSourceLabels = ({
|
|
|
1694
1714
|
provenanceLabel
|
|
1695
1715
|
};
|
|
1696
1716
|
};
|
|
1717
|
+
var buildRAGChunkStructure = (metadata) => {
|
|
1718
|
+
if (!metadata) {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
1722
|
+
const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" ? metadata.sectionKind : undefined;
|
|
1723
|
+
const section = {
|
|
1724
|
+
depth: getContextNumber2(metadata.sectionDepth),
|
|
1725
|
+
kind: sectionKind,
|
|
1726
|
+
path: sectionPath && sectionPath.length > 0 ? sectionPath : undefined,
|
|
1727
|
+
title: getContextString2(metadata.sectionTitle)
|
|
1728
|
+
};
|
|
1729
|
+
const sequence = {
|
|
1730
|
+
nextChunkId: getContextString2(metadata.nextChunkId),
|
|
1731
|
+
previousChunkId: getContextString2(metadata.previousChunkId),
|
|
1732
|
+
sectionChunkCount: getContextNumber2(metadata.sectionChunkCount),
|
|
1733
|
+
sectionChunkId: getContextString2(metadata.sectionChunkId),
|
|
1734
|
+
sectionChunkIndex: getContextNumber2(metadata.sectionChunkIndex)
|
|
1735
|
+
};
|
|
1736
|
+
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") {
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
return {
|
|
1740
|
+
section: section.title || section.path && section.path.length > 0 || typeof section.depth === "number" || section.kind ? section : undefined,
|
|
1741
|
+
sequence: sequence.nextChunkId || sequence.previousChunkId || typeof sequence.sectionChunkCount === "number" || sequence.sectionChunkId || typeof sequence.sectionChunkIndex === "number" ? sequence : undefined
|
|
1742
|
+
};
|
|
1743
|
+
};
|
|
1697
1744
|
var buildExcerpt2 = (text, maxLength = 160) => {
|
|
1698
1745
|
const normalized = text.replaceAll(/\s+/g, " ").trim();
|
|
1699
1746
|
if (normalized.length <= maxLength) {
|
|
@@ -1701,6 +1748,136 @@ var buildExcerpt2 = (text, maxLength = 160) => {
|
|
|
1701
1748
|
}
|
|
1702
1749
|
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
1703
1750
|
};
|
|
1751
|
+
var buildRAGChunkGraph = (chunks) => {
|
|
1752
|
+
const nodes = [];
|
|
1753
|
+
const edges = [];
|
|
1754
|
+
const edgeKeys = new Set;
|
|
1755
|
+
const sections = new Map;
|
|
1756
|
+
for (const chunk of chunks) {
|
|
1757
|
+
const labels = chunk.labels ?? buildRAGSourceLabels({
|
|
1758
|
+
metadata: chunk.metadata,
|
|
1759
|
+
source: chunk.source,
|
|
1760
|
+
title: chunk.title
|
|
1761
|
+
});
|
|
1762
|
+
const structure = chunk.structure ?? buildRAGChunkStructure(chunk.metadata);
|
|
1763
|
+
nodes.push({
|
|
1764
|
+
chunkId: chunk.chunkId,
|
|
1765
|
+
contextLabel: labels?.contextLabel,
|
|
1766
|
+
label: chunk.source ?? chunk.title ?? chunk.chunkId,
|
|
1767
|
+
locatorLabel: labels?.locatorLabel,
|
|
1768
|
+
provenanceLabel: labels?.provenanceLabel,
|
|
1769
|
+
score: chunk.score,
|
|
1770
|
+
source: chunk.source,
|
|
1771
|
+
structure,
|
|
1772
|
+
title: chunk.title
|
|
1773
|
+
});
|
|
1774
|
+
const previousChunkId = structure?.sequence?.previousChunkId;
|
|
1775
|
+
if (previousChunkId) {
|
|
1776
|
+
const key = `previous:${previousChunkId}:${chunk.chunkId}`;
|
|
1777
|
+
if (!edgeKeys.has(key)) {
|
|
1778
|
+
edgeKeys.add(key);
|
|
1779
|
+
edges.push({
|
|
1780
|
+
fromChunkId: previousChunkId,
|
|
1781
|
+
relation: "previous",
|
|
1782
|
+
toChunkId: chunk.chunkId
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
const nextChunkId = structure?.sequence?.nextChunkId;
|
|
1787
|
+
if (nextChunkId) {
|
|
1788
|
+
const key = `next:${chunk.chunkId}:${nextChunkId}`;
|
|
1789
|
+
if (!edgeKeys.has(key)) {
|
|
1790
|
+
edgeKeys.add(key);
|
|
1791
|
+
edges.push({
|
|
1792
|
+
fromChunkId: chunk.chunkId,
|
|
1793
|
+
relation: "next",
|
|
1794
|
+
toChunkId: nextChunkId
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
const sectionId = structure?.sequence?.sectionChunkId;
|
|
1799
|
+
if (sectionId) {
|
|
1800
|
+
const existing = sections.get(sectionId);
|
|
1801
|
+
if (!existing) {
|
|
1802
|
+
sections.set(sectionId, {
|
|
1803
|
+
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1804
|
+
chunkIds: [chunk.chunkId],
|
|
1805
|
+
depth: structure.section?.depth,
|
|
1806
|
+
id: sectionId,
|
|
1807
|
+
kind: structure.section?.kind,
|
|
1808
|
+
path: structure.section?.path,
|
|
1809
|
+
title: structure.section?.title
|
|
1810
|
+
});
|
|
1811
|
+
continue;
|
|
1812
|
+
}
|
|
1813
|
+
if (!existing.chunkIds.includes(chunk.chunkId)) {
|
|
1814
|
+
existing.chunkIds.push(chunk.chunkId);
|
|
1815
|
+
}
|
|
1816
|
+
existing.chunkCount = Math.max(existing.chunkCount, structure.sequence?.sectionChunkCount ?? existing.chunkCount);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
for (const section of sections.values()) {
|
|
1820
|
+
section.chunkIds.sort((left, right) => {
|
|
1821
|
+
const leftNode = nodes.find((node) => node.chunkId === left);
|
|
1822
|
+
const rightNode = nodes.find((node) => node.chunkId === right);
|
|
1823
|
+
const leftIndex = leftNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1824
|
+
const rightIndex = rightNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1825
|
+
if (leftIndex !== rightIndex) {
|
|
1826
|
+
return leftIndex - rightIndex;
|
|
1827
|
+
}
|
|
1828
|
+
return left.localeCompare(right);
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
nodes.sort((left, right) => {
|
|
1832
|
+
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1833
|
+
const rightSection = right.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1834
|
+
if (leftSection !== rightSection) {
|
|
1835
|
+
return leftSection - rightSection;
|
|
1836
|
+
}
|
|
1837
|
+
const leftScore = left.score ?? Number.NEGATIVE_INFINITY;
|
|
1838
|
+
const rightScore = right.score ?? Number.NEGATIVE_INFINITY;
|
|
1839
|
+
if (leftScore !== rightScore) {
|
|
1840
|
+
return rightScore - leftScore;
|
|
1841
|
+
}
|
|
1842
|
+
return left.label.localeCompare(right.label);
|
|
1843
|
+
});
|
|
1844
|
+
return {
|
|
1845
|
+
edges,
|
|
1846
|
+
nodes,
|
|
1847
|
+
sections: [...sections.values()].sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
|
|
1848
|
+
};
|
|
1849
|
+
};
|
|
1850
|
+
var buildRAGChunkPreviewGraph = (preview) => buildRAGChunkGraph(preview.chunks.map((chunk) => ({
|
|
1851
|
+
chunkId: chunk.chunkId,
|
|
1852
|
+
labels: chunk.labels,
|
|
1853
|
+
metadata: chunk.metadata,
|
|
1854
|
+
source: chunk.source ?? preview.document.source,
|
|
1855
|
+
structure: chunk.structure,
|
|
1856
|
+
title: chunk.title ?? preview.document.title
|
|
1857
|
+
})));
|
|
1858
|
+
var buildRAGChunkPreviewNavigation = (preview, activeChunkId) => buildRAGChunkGraphNavigation(buildRAGChunkPreviewGraph(preview), activeChunkId);
|
|
1859
|
+
var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
1860
|
+
if (graph.nodes.length === 0) {
|
|
1861
|
+
return {
|
|
1862
|
+
activeChunkId,
|
|
1863
|
+
sectionNodes: []
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
const activeNode = (activeChunkId ? graph.nodes.find((node) => node.chunkId === activeChunkId) : undefined) ?? graph.nodes[0];
|
|
1867
|
+
const resolvedActiveChunkId = activeNode?.chunkId;
|
|
1868
|
+
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1869
|
+
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1870
|
+
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1871
|
+
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1872
|
+
return {
|
|
1873
|
+
activeChunkId: resolvedActiveChunkId,
|
|
1874
|
+
activeNode,
|
|
1875
|
+
nextNode,
|
|
1876
|
+
previousNode,
|
|
1877
|
+
section,
|
|
1878
|
+
sectionNodes
|
|
1879
|
+
};
|
|
1880
|
+
};
|
|
1704
1881
|
var buildRAGRetrievedState = (messages) => {
|
|
1705
1882
|
const message = getLatestRetrievedMessage(messages);
|
|
1706
1883
|
if (!message) {
|
|
@@ -1742,6 +1919,7 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
1742
1919
|
label: group.label,
|
|
1743
1920
|
locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
|
|
1744
1921
|
provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
|
|
1922
|
+
structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
|
|
1745
1923
|
source: group.source,
|
|
1746
1924
|
title: group.title
|
|
1747
1925
|
};
|
|
@@ -1870,6 +2048,7 @@ var buildSourceGroup = (source, key) => ({
|
|
|
1870
2048
|
source: source.source,
|
|
1871
2049
|
title: source.title
|
|
1872
2050
|
}),
|
|
2051
|
+
structure: source.structure ?? buildRAGChunkStructure(source.metadata),
|
|
1873
2052
|
source: source.source,
|
|
1874
2053
|
title: source.title
|
|
1875
2054
|
});
|
|
@@ -1888,6 +2067,7 @@ var updateSourceGroup = (groups, source) => {
|
|
|
1888
2067
|
source: source.source,
|
|
1889
2068
|
title: source.title
|
|
1890
2069
|
});
|
|
2070
|
+
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
1891
2071
|
existing.source = source.source;
|
|
1892
2072
|
existing.title = source.title;
|
|
1893
2073
|
} else {
|
|
@@ -3902,5 +4082,5 @@ export {
|
|
|
3902
4082
|
AIStreamService
|
|
3903
4083
|
};
|
|
3904
4084
|
|
|
3905
|
-
//# debugId=
|
|
4085
|
+
//# debugId=1D0F4342CA655E9164756E2164756E21
|
|
3906
4086
|
//# sourceMappingURL=index.js.map
|