@absolutejs/absolute 0.19.0-beta.603 → 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.
Files changed (39) hide show
  1. package/dist/ai/client/index.js +244 -10
  2. package/dist/ai/client/index.js.map +4 -4
  3. package/dist/ai/client/ui.js +248 -10
  4. package/dist/ai/client/ui.js.map +4 -4
  5. package/dist/ai/index.js +1003 -110
  6. package/dist/ai/index.js.map +8 -8
  7. package/dist/ai/rag/quality.js +27 -6
  8. package/dist/ai/rag/quality.js.map +3 -3
  9. package/dist/ai/rag/ui.js +248 -10
  10. package/dist/ai/rag/ui.js.map +4 -4
  11. package/dist/ai-client/angular/ai/index.js +243 -9
  12. package/dist/ai-client/react/ai/index.js +258 -10
  13. package/dist/ai-client/vue/ai/index.js +347 -101
  14. package/dist/angular/ai/index.js +244 -10
  15. package/dist/angular/ai/index.js.map +4 -4
  16. package/dist/react/ai/index.js +259 -11
  17. package/dist/react/ai/index.js.map +6 -6
  18. package/dist/src/ai/client/ui.d.ts +1 -1
  19. package/dist/src/ai/rag/index.d.ts +1 -1
  20. package/dist/src/ai/rag/presentation.d.ts +12 -1
  21. package/dist/src/ai/rag/ui.d.ts +1 -1
  22. package/dist/src/react/ai/useRAG.d.ts +5 -0
  23. package/dist/src/react/ai/useRAGChunkPreview.d.ts +4 -0
  24. package/dist/src/react/ai/useRAGSources.d.ts +1 -0
  25. package/dist/src/svelte/ai/createRAG.d.ts +5 -0
  26. package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +4 -0
  27. package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
  28. package/dist/src/vue/ai/useRAG.d.ts +125 -0
  29. package/dist/src/vue/ai/useRAGChunkPreview.d.ts +54 -0
  30. package/dist/src/vue/ai/useRAGDocuments.d.ts +20 -0
  31. package/dist/src/vue/ai/useRAGIndexAdmin.d.ts +10 -0
  32. package/dist/src/vue/ai/useRAGSearch.d.ts +40 -0
  33. package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
  34. package/dist/svelte/ai/index.js +305 -57
  35. package/dist/svelte/ai/index.js.map +6 -6
  36. package/dist/types/ai.d.ts +102 -1
  37. package/dist/vue/ai/index.js +311 -63
  38. package/dist/vue/ai/index.js.map +6 -6
  39. package/package.json +1 -1
@@ -883,6 +883,10 @@ var buildContextLabel = (metadata) => {
883
883
  return from ? `Message from ${from}` : "Message evidence";
884
884
  }
885
885
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
886
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
887
+ if (page && region) {
888
+ return `Page ${page} region ${region}`;
889
+ }
886
890
  if (page) {
887
891
  return `Page ${page}`;
888
892
  }
@@ -906,6 +910,11 @@ var buildContextLabel = (metadata) => {
906
910
  if (speaker) {
907
911
  return `Speaker ${speaker}`;
908
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
+ }
909
918
  return;
910
919
  };
911
920
  var formatMediaTimestamp = (value) => {
@@ -923,6 +932,10 @@ var buildLocatorLabel = (metadata, source, title) => {
923
932
  return;
924
933
  }
925
934
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
935
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
936
+ if (page && region) {
937
+ return `Page ${page} \xB7 Region ${region}`;
938
+ }
926
939
  if (page) {
927
940
  return `Page ${page}`;
928
941
  }
@@ -951,6 +964,10 @@ var buildLocatorLabel = (metadata, source, title) => {
951
964
  if (mediaStart) {
952
965
  return `Timestamp ${mediaStart}`;
953
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
+ }
954
971
  return;
955
972
  };
956
973
  var formatTimestampLabel = (value) => {
@@ -975,9 +992,11 @@ var buildProvenanceLabel = (metadata) => {
975
992
  const transcriptSource = getContextString(metadata.transcriptSource);
976
993
  const pdfTextMode = getContextString(metadata.pdfTextMode);
977
994
  const ocrEngine = getContextString(metadata.ocrEngine);
995
+ const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
978
996
  const labels = [
979
997
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
980
998
  ocrEngine ? `OCR ${ocrEngine}` : "",
999
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
981
1000
  mediaKind ? `Media ${mediaKind}` : "",
982
1001
  transcriptSource ? `Transcript ${transcriptSource}` : "",
983
1002
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -998,8 +1017,10 @@ var buildExcerpt = (text, maxLength = 160) => {
998
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 ");
999
1018
  var buildGroundingReferenceEvidenceSummary = (reference) => [
1000
1019
  reference.source ?? reference.title ?? reference.chunkId,
1020
+ reference.locatorLabel,
1021
+ reference.contextLabel,
1001
1022
  reference.provenanceLabel
1002
- ].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 ");
1003
1024
  var buildGroundedAnswerCitationDetail = (reference) => ({
1004
1025
  contextLabel: reference.contextLabel,
1005
1026
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
@@ -1023,12 +1044,12 @@ var buildRAGCitations = (sources) => {
1023
1044
  continue;
1024
1045
  unique.set(key, {
1025
1046
  chunkId: source.chunkId,
1026
- contextLabel: buildContextLabel(source.metadata),
1047
+ contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
1027
1048
  key,
1028
1049
  label: buildSourceLabel(source),
1029
- locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
1050
+ locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
1030
1051
  metadata: source.metadata,
1031
- provenanceLabel: buildProvenanceLabel(source.metadata),
1052
+ provenanceLabel: source.labels?.provenanceLabel ?? buildProvenanceLabel(source.metadata),
1032
1053
  score: source.score,
1033
1054
  source: source.source,
1034
1055
  text: source.text,
@@ -1098,7 +1119,7 @@ var buildRAGGroundingReferences = (sources) => {
1098
1119
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
1099
1120
  return citations.map((citation) => ({
1100
1121
  chunkId: citation.chunkId,
1101
- contextLabel: buildContextLabel(citation.metadata),
1122
+ contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
1102
1123
  excerpt: buildExcerpt(citation.text),
1103
1124
  label: citation.label,
1104
1125
  locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
@@ -1573,6 +1594,10 @@ var buildContextLabel2 = (metadata) => {
1573
1594
  return from ? `Message from ${from}` : "Message evidence";
1574
1595
  }
1575
1596
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1597
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
1598
+ if (page && region) {
1599
+ return `Page ${page} region ${region}`;
1600
+ }
1576
1601
  if (page) {
1577
1602
  return `Page ${page}`;
1578
1603
  }
@@ -1596,6 +1621,11 @@ var buildContextLabel2 = (metadata) => {
1596
1621
  if (speaker) {
1597
1622
  return `Speaker ${speaker}`;
1598
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
+ }
1599
1629
  return;
1600
1630
  };
1601
1631
  var buildLocatorLabel2 = (metadata, source, title) => {
@@ -1603,6 +1633,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1603
1633
  return;
1604
1634
  }
1605
1635
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1636
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
1637
+ if (page && region) {
1638
+ return `Page ${page} \xB7 Region ${region}`;
1639
+ }
1606
1640
  if (page) {
1607
1641
  return `Page ${page}`;
1608
1642
  }
@@ -1631,6 +1665,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1631
1665
  if (mediaStart) {
1632
1666
  return `Timestamp ${mediaStart}`;
1633
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
+ }
1634
1672
  return;
1635
1673
  };
1636
1674
  var buildProvenanceLabel2 = (metadata) => {
@@ -1645,9 +1683,11 @@ var buildProvenanceLabel2 = (metadata) => {
1645
1683
  const transcriptSource = getContextString2(metadata.transcriptSource);
1646
1684
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
1647
1685
  const ocrEngine = getContextString2(metadata.ocrEngine);
1686
+ const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
1648
1687
  const labels = [
1649
1688
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
1650
1689
  ocrEngine ? `OCR ${ocrEngine}` : "",
1690
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
1651
1691
  mediaKind ? `Media ${mediaKind}` : "",
1652
1692
  transcriptSource ? `Transcript ${transcriptSource}` : "",
1653
1693
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -1657,6 +1697,50 @@ var buildProvenanceLabel2 = (metadata) => {
1657
1697
  ].filter((value) => value.length > 0);
1658
1698
  return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
1659
1699
  };
1700
+ var buildRAGSourceLabels = ({
1701
+ metadata,
1702
+ source,
1703
+ title
1704
+ }) => {
1705
+ const contextLabel = buildContextLabel2(metadata);
1706
+ const locatorLabel = buildLocatorLabel2(metadata, source, title);
1707
+ const provenanceLabel = buildProvenanceLabel2(metadata);
1708
+ if (!contextLabel && !locatorLabel && !provenanceLabel) {
1709
+ return;
1710
+ }
1711
+ return {
1712
+ contextLabel,
1713
+ locatorLabel,
1714
+ provenanceLabel
1715
+ };
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
+ };
1660
1744
  var buildExcerpt2 = (text, maxLength = 160) => {
1661
1745
  const normalized = text.replaceAll(/\s+/g, " ").trim();
1662
1746
  if (normalized.length <= maxLength) {
@@ -1664,6 +1748,136 @@ var buildExcerpt2 = (text, maxLength = 160) => {
1664
1748
  }
1665
1749
  return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
1666
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
+ };
1667
1881
  var buildRAGRetrievedState = (messages) => {
1668
1882
  const message = getLatestRetrievedMessage(messages);
1669
1883
  if (!message) {
@@ -1698,13 +1912,14 @@ var buildRAGSourceSummaries = (sources) => {
1698
1912
  citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
1699
1913
  citations: groupCitations,
1700
1914
  chunkIds: group.chunks.map((chunk) => chunk.chunkId),
1701
- contextLabel: buildContextLabel2(leadChunk?.metadata),
1915
+ contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
1702
1916
  count: group.count,
1703
1917
  excerpt: buildExcerpt2(leadChunk?.text ?? ""),
1704
1918
  key: group.key,
1705
1919
  label: group.label,
1706
- locatorLabel: buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
1707
- provenanceLabel: buildProvenanceLabel2(leadChunk?.metadata),
1920
+ locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
1921
+ provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
1922
+ structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
1708
1923
  source: group.source,
1709
1924
  title: group.title
1710
1925
  };
@@ -1828,6 +2043,12 @@ var buildSourceGroup = (source, key) => ({
1828
2043
  count: 1,
1829
2044
  key,
1830
2045
  label: buildSourceLabel2(source),
2046
+ labels: source.labels ?? buildRAGSourceLabels({
2047
+ metadata: source.metadata,
2048
+ source: source.source,
2049
+ title: source.title
2050
+ }),
2051
+ structure: source.structure ?? buildRAGChunkStructure(source.metadata),
1831
2052
  source: source.source,
1832
2053
  title: source.title
1833
2054
  });
@@ -1838,7 +2059,20 @@ var updateSourceGroup = (groups, source) => {
1838
2059
  groups.set(key, buildSourceGroup(source, key));
1839
2060
  return;
1840
2061
  }
1841
- existing.bestScore = Math.max(existing.bestScore, source.score);
2062
+ if (source.score > existing.bestScore) {
2063
+ existing.bestScore = source.score;
2064
+ existing.label = buildSourceLabel2(source);
2065
+ existing.labels = source.labels ?? buildRAGSourceLabels({
2066
+ metadata: source.metadata,
2067
+ source: source.source,
2068
+ title: source.title
2069
+ });
2070
+ existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
2071
+ existing.source = source.source;
2072
+ existing.title = source.title;
2073
+ } else {
2074
+ existing.bestScore = Math.max(existing.bestScore, source.score);
2075
+ }
1842
2076
  existing.count += 1;
1843
2077
  existing.chunks.push(source);
1844
2078
  };
@@ -3848,5 +4082,5 @@ export {
3848
4082
  AIStreamService
3849
4083
  };
3850
4084
 
3851
- //# debugId=EC6F974D3E81C60A64756E2164756E21
4085
+ //# debugId=1D0F4342CA655E9164756E2164756E21
3852
4086
  //# sourceMappingURL=index.js.map