@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
@@ -216,6 +216,10 @@ var buildContextLabel = (metadata) => {
216
216
  return from ? `Message from ${from}` : "Message evidence";
217
217
  }
218
218
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
219
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
220
+ if (page && region) {
221
+ return `Page ${page} region ${region}`;
222
+ }
219
223
  if (page) {
220
224
  return `Page ${page}`;
221
225
  }
@@ -239,6 +243,11 @@ var buildContextLabel = (metadata) => {
239
243
  if (speaker) {
240
244
  return `Speaker ${speaker}`;
241
245
  }
246
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
247
+ const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
248
+ if (sectionTitle) {
249
+ return `Section ${sectionTitle}`;
250
+ }
242
251
  return;
243
252
  };
244
253
  var formatMediaTimestamp = (value) => {
@@ -256,6 +265,10 @@ var buildLocatorLabel = (metadata, source, title) => {
256
265
  return;
257
266
  }
258
267
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
268
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
269
+ if (page && region) {
270
+ return `Page ${page} \xB7 Region ${region}`;
271
+ }
259
272
  if (page) {
260
273
  return `Page ${page}`;
261
274
  }
@@ -284,6 +297,10 @@ var buildLocatorLabel = (metadata, source, title) => {
284
297
  if (mediaStart) {
285
298
  return `Timestamp ${mediaStart}`;
286
299
  }
300
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
301
+ if (sectionPath.length > 0) {
302
+ return `Section ${sectionPath.join(" > ")}`;
303
+ }
287
304
  return;
288
305
  };
289
306
  var formatTimestampLabel = (value) => {
@@ -308,9 +325,11 @@ var buildProvenanceLabel = (metadata) => {
308
325
  const transcriptSource = getContextString(metadata.transcriptSource);
309
326
  const pdfTextMode = getContextString(metadata.pdfTextMode);
310
327
  const ocrEngine = getContextString(metadata.ocrEngine);
328
+ const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
311
329
  const labels = [
312
330
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
313
331
  ocrEngine ? `OCR ${ocrEngine}` : "",
332
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
314
333
  mediaKind ? `Media ${mediaKind}` : "",
315
334
  transcriptSource ? `Transcript ${transcriptSource}` : "",
316
335
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -331,8 +350,10 @@ var buildExcerpt = (text, maxLength = 160) => {
331
350
  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 ");
332
351
  var buildGroundingReferenceEvidenceSummary = (reference) => [
333
352
  reference.source ?? reference.title ?? reference.chunkId,
353
+ reference.locatorLabel,
354
+ reference.contextLabel,
334
355
  reference.provenanceLabel
335
- ].filter((value) => Boolean(value && value.length > 0)).join(" \xB7 ");
356
+ ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
336
357
  var buildGroundedAnswerCitationDetail = (reference) => ({
337
358
  contextLabel: reference.contextLabel,
338
359
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
@@ -356,12 +377,12 @@ var buildRAGCitations = (sources) => {
356
377
  continue;
357
378
  unique.set(key, {
358
379
  chunkId: source.chunkId,
359
- contextLabel: buildContextLabel(source.metadata),
380
+ contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
360
381
  key,
361
382
  label: buildSourceLabel(source),
362
- locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
383
+ locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
363
384
  metadata: source.metadata,
364
- provenanceLabel: buildProvenanceLabel(source.metadata),
385
+ provenanceLabel: source.labels?.provenanceLabel ?? buildProvenanceLabel(source.metadata),
365
386
  score: source.score,
366
387
  source: source.source,
367
388
  text: source.text,
@@ -431,7 +452,7 @@ var buildRAGGroundingReferences = (sources) => {
431
452
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
432
453
  return citations.map((citation) => ({
433
454
  chunkId: citation.chunkId,
434
- contextLabel: buildContextLabel(citation.metadata),
455
+ contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
435
456
  excerpt: buildExcerpt(citation.text),
436
457
  label: citation.label,
437
458
  locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
@@ -4574,6 +4595,10 @@ var buildContextLabel2 = (metadata) => {
4574
4595
  return from ? `Message from ${from}` : "Message evidence";
4575
4596
  }
4576
4597
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
4598
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
4599
+ if (page && region) {
4600
+ return `Page ${page} region ${region}`;
4601
+ }
4577
4602
  if (page) {
4578
4603
  return `Page ${page}`;
4579
4604
  }
@@ -4597,6 +4622,11 @@ var buildContextLabel2 = (metadata) => {
4597
4622
  if (speaker) {
4598
4623
  return `Speaker ${speaker}`;
4599
4624
  }
4625
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
4626
+ const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
4627
+ if (sectionTitle) {
4628
+ return `Section ${sectionTitle}`;
4629
+ }
4600
4630
  return;
4601
4631
  };
4602
4632
  var buildLocatorLabel2 = (metadata, source, title) => {
@@ -4604,6 +4634,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
4604
4634
  return;
4605
4635
  }
4606
4636
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
4637
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
4638
+ if (page && region) {
4639
+ return `Page ${page} \xB7 Region ${region}`;
4640
+ }
4607
4641
  if (page) {
4608
4642
  return `Page ${page}`;
4609
4643
  }
@@ -4632,6 +4666,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
4632
4666
  if (mediaStart) {
4633
4667
  return `Timestamp ${mediaStart}`;
4634
4668
  }
4669
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
4670
+ if (sectionPath.length > 0) {
4671
+ return `Section ${sectionPath.join(" > ")}`;
4672
+ }
4635
4673
  return;
4636
4674
  };
4637
4675
  var buildProvenanceLabel2 = (metadata) => {
@@ -4646,9 +4684,11 @@ var buildProvenanceLabel2 = (metadata) => {
4646
4684
  const transcriptSource = getContextString2(metadata.transcriptSource);
4647
4685
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
4648
4686
  const ocrEngine = getContextString2(metadata.ocrEngine);
4687
+ const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
4649
4688
  const labels = [
4650
4689
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
4651
4690
  ocrEngine ? `OCR ${ocrEngine}` : "",
4691
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
4652
4692
  mediaKind ? `Media ${mediaKind}` : "",
4653
4693
  transcriptSource ? `Transcript ${transcriptSource}` : "",
4654
4694
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -4658,6 +4698,50 @@ var buildProvenanceLabel2 = (metadata) => {
4658
4698
  ].filter((value) => value.length > 0);
4659
4699
  return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
4660
4700
  };
4701
+ var buildRAGSourceLabels = ({
4702
+ metadata,
4703
+ source,
4704
+ title
4705
+ }) => {
4706
+ const contextLabel = buildContextLabel2(metadata);
4707
+ const locatorLabel = buildLocatorLabel2(metadata, source, title);
4708
+ const provenanceLabel = buildProvenanceLabel2(metadata);
4709
+ if (!contextLabel && !locatorLabel && !provenanceLabel) {
4710
+ return;
4711
+ }
4712
+ return {
4713
+ contextLabel,
4714
+ locatorLabel,
4715
+ provenanceLabel
4716
+ };
4717
+ };
4718
+ var buildRAGChunkStructure = (metadata) => {
4719
+ if (!metadata) {
4720
+ return;
4721
+ }
4722
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
4723
+ const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" ? metadata.sectionKind : undefined;
4724
+ const section = {
4725
+ depth: getContextNumber2(metadata.sectionDepth),
4726
+ kind: sectionKind,
4727
+ path: sectionPath && sectionPath.length > 0 ? sectionPath : undefined,
4728
+ title: getContextString2(metadata.sectionTitle)
4729
+ };
4730
+ const sequence = {
4731
+ nextChunkId: getContextString2(metadata.nextChunkId),
4732
+ previousChunkId: getContextString2(metadata.previousChunkId),
4733
+ sectionChunkCount: getContextNumber2(metadata.sectionChunkCount),
4734
+ sectionChunkId: getContextString2(metadata.sectionChunkId),
4735
+ sectionChunkIndex: getContextNumber2(metadata.sectionChunkIndex)
4736
+ };
4737
+ 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") {
4738
+ return;
4739
+ }
4740
+ return {
4741
+ section: section.title || section.path && section.path.length > 0 || typeof section.depth === "number" || section.kind ? section : undefined,
4742
+ sequence: sequence.nextChunkId || sequence.previousChunkId || typeof sequence.sectionChunkCount === "number" || sequence.sectionChunkId || typeof sequence.sectionChunkIndex === "number" ? sequence : undefined
4743
+ };
4744
+ };
4661
4745
  var buildExcerpt2 = (text, maxLength = 160) => {
4662
4746
  const normalized = text.replaceAll(/\s+/g, " ").trim();
4663
4747
  if (normalized.length <= maxLength) {
@@ -4665,6 +4749,136 @@ var buildExcerpt2 = (text, maxLength = 160) => {
4665
4749
  }
4666
4750
  return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
4667
4751
  };
4752
+ var buildRAGChunkGraph = (chunks) => {
4753
+ const nodes = [];
4754
+ const edges = [];
4755
+ const edgeKeys = new Set;
4756
+ const sections = new Map;
4757
+ for (const chunk of chunks) {
4758
+ const labels = chunk.labels ?? buildRAGSourceLabels({
4759
+ metadata: chunk.metadata,
4760
+ source: chunk.source,
4761
+ title: chunk.title
4762
+ });
4763
+ const structure = chunk.structure ?? buildRAGChunkStructure(chunk.metadata);
4764
+ nodes.push({
4765
+ chunkId: chunk.chunkId,
4766
+ contextLabel: labels?.contextLabel,
4767
+ label: chunk.source ?? chunk.title ?? chunk.chunkId,
4768
+ locatorLabel: labels?.locatorLabel,
4769
+ provenanceLabel: labels?.provenanceLabel,
4770
+ score: chunk.score,
4771
+ source: chunk.source,
4772
+ structure,
4773
+ title: chunk.title
4774
+ });
4775
+ const previousChunkId = structure?.sequence?.previousChunkId;
4776
+ if (previousChunkId) {
4777
+ const key = `previous:${previousChunkId}:${chunk.chunkId}`;
4778
+ if (!edgeKeys.has(key)) {
4779
+ edgeKeys.add(key);
4780
+ edges.push({
4781
+ fromChunkId: previousChunkId,
4782
+ relation: "previous",
4783
+ toChunkId: chunk.chunkId
4784
+ });
4785
+ }
4786
+ }
4787
+ const nextChunkId = structure?.sequence?.nextChunkId;
4788
+ if (nextChunkId) {
4789
+ const key = `next:${chunk.chunkId}:${nextChunkId}`;
4790
+ if (!edgeKeys.has(key)) {
4791
+ edgeKeys.add(key);
4792
+ edges.push({
4793
+ fromChunkId: chunk.chunkId,
4794
+ relation: "next",
4795
+ toChunkId: nextChunkId
4796
+ });
4797
+ }
4798
+ }
4799
+ const sectionId = structure?.sequence?.sectionChunkId;
4800
+ if (sectionId) {
4801
+ const existing = sections.get(sectionId);
4802
+ if (!existing) {
4803
+ sections.set(sectionId, {
4804
+ chunkCount: structure.sequence?.sectionChunkCount ?? 1,
4805
+ chunkIds: [chunk.chunkId],
4806
+ depth: structure.section?.depth,
4807
+ id: sectionId,
4808
+ kind: structure.section?.kind,
4809
+ path: structure.section?.path,
4810
+ title: structure.section?.title
4811
+ });
4812
+ continue;
4813
+ }
4814
+ if (!existing.chunkIds.includes(chunk.chunkId)) {
4815
+ existing.chunkIds.push(chunk.chunkId);
4816
+ }
4817
+ existing.chunkCount = Math.max(existing.chunkCount, structure.sequence?.sectionChunkCount ?? existing.chunkCount);
4818
+ }
4819
+ }
4820
+ for (const section of sections.values()) {
4821
+ section.chunkIds.sort((left, right) => {
4822
+ const leftNode = nodes.find((node) => node.chunkId === left);
4823
+ const rightNode = nodes.find((node) => node.chunkId === right);
4824
+ const leftIndex = leftNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
4825
+ const rightIndex = rightNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
4826
+ if (leftIndex !== rightIndex) {
4827
+ return leftIndex - rightIndex;
4828
+ }
4829
+ return left.localeCompare(right);
4830
+ });
4831
+ }
4832
+ nodes.sort((left, right) => {
4833
+ const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
4834
+ const rightSection = right.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
4835
+ if (leftSection !== rightSection) {
4836
+ return leftSection - rightSection;
4837
+ }
4838
+ const leftScore = left.score ?? Number.NEGATIVE_INFINITY;
4839
+ const rightScore = right.score ?? Number.NEGATIVE_INFINITY;
4840
+ if (leftScore !== rightScore) {
4841
+ return rightScore - leftScore;
4842
+ }
4843
+ return left.label.localeCompare(right.label);
4844
+ });
4845
+ return {
4846
+ edges,
4847
+ nodes,
4848
+ sections: [...sections.values()].sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
4849
+ };
4850
+ };
4851
+ var buildRAGChunkPreviewGraph = (preview) => buildRAGChunkGraph(preview.chunks.map((chunk) => ({
4852
+ chunkId: chunk.chunkId,
4853
+ labels: chunk.labels,
4854
+ metadata: chunk.metadata,
4855
+ source: chunk.source ?? preview.document.source,
4856
+ structure: chunk.structure,
4857
+ title: chunk.title ?? preview.document.title
4858
+ })));
4859
+ var buildRAGChunkPreviewNavigation = (preview, activeChunkId) => buildRAGChunkGraphNavigation(buildRAGChunkPreviewGraph(preview), activeChunkId);
4860
+ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4861
+ if (graph.nodes.length === 0) {
4862
+ return {
4863
+ activeChunkId,
4864
+ sectionNodes: []
4865
+ };
4866
+ }
4867
+ const activeNode = (activeChunkId ? graph.nodes.find((node) => node.chunkId === activeChunkId) : undefined) ?? graph.nodes[0];
4868
+ const resolvedActiveChunkId = activeNode?.chunkId;
4869
+ const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
4870
+ const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
4871
+ const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
4872
+ const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
4873
+ return {
4874
+ activeChunkId: resolvedActiveChunkId,
4875
+ activeNode,
4876
+ nextNode,
4877
+ previousNode,
4878
+ section,
4879
+ sectionNodes
4880
+ };
4881
+ };
4668
4882
  var buildRAGRetrievedState = (messages) => {
4669
4883
  const message = getLatestRetrievedMessage(messages);
4670
4884
  if (!message) {
@@ -4699,13 +4913,14 @@ var buildRAGSourceSummaries = (sources) => {
4699
4913
  citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
4700
4914
  citations: groupCitations,
4701
4915
  chunkIds: group.chunks.map((chunk) => chunk.chunkId),
4702
- contextLabel: buildContextLabel2(leadChunk?.metadata),
4916
+ contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
4703
4917
  count: group.count,
4704
4918
  excerpt: buildExcerpt2(leadChunk?.text ?? ""),
4705
4919
  key: group.key,
4706
4920
  label: group.label,
4707
- locatorLabel: buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
4708
- provenanceLabel: buildProvenanceLabel2(leadChunk?.metadata),
4921
+ locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
4922
+ provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
4923
+ structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
4709
4924
  source: group.source,
4710
4925
  title: group.title
4711
4926
  };
@@ -4829,6 +5044,12 @@ var buildSourceGroup = (source, key) => ({
4829
5044
  count: 1,
4830
5045
  key,
4831
5046
  label: buildSourceLabel2(source),
5047
+ labels: source.labels ?? buildRAGSourceLabels({
5048
+ metadata: source.metadata,
5049
+ source: source.source,
5050
+ title: source.title
5051
+ }),
5052
+ structure: source.structure ?? buildRAGChunkStructure(source.metadata),
4832
5053
  source: source.source,
4833
5054
  title: source.title
4834
5055
  });
@@ -4839,7 +5060,20 @@ var updateSourceGroup = (groups, source) => {
4839
5060
  groups.set(key, buildSourceGroup(source, key));
4840
5061
  return;
4841
5062
  }
4842
- existing.bestScore = Math.max(existing.bestScore, source.score);
5063
+ if (source.score > existing.bestScore) {
5064
+ existing.bestScore = source.score;
5065
+ existing.label = buildSourceLabel2(source);
5066
+ existing.labels = source.labels ?? buildRAGSourceLabels({
5067
+ metadata: source.metadata,
5068
+ source: source.source,
5069
+ title: source.title
5070
+ });
5071
+ existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
5072
+ existing.source = source.source;
5073
+ existing.title = source.title;
5074
+ } else {
5075
+ existing.bestScore = Math.max(existing.bestScore, source.score);
5076
+ }
4843
5077
  existing.count += 1;
4844
5078
  existing.chunks.push(source);
4845
5079
  };
@@ -6614,5 +6848,5 @@ export {
6614
6848
  buildRAGEvaluationLeaderboard
6615
6849
  };
6616
6850
 
6617
- //# debugId=BF84F684839B69B464756E2164756E21
6851
+ //# debugId=C86DB4BD7A51410264756E2164756E21
6618
6852
  //# sourceMappingURL=index.js.map