@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.
Files changed (37) hide show
  1. package/dist/ai/client/index.js +112 -1
  2. package/dist/ai/client/index.js.map +4 -4
  3. package/dist/ai/client/ui.js +113 -1
  4. package/dist/ai/client/ui.js.map +4 -4
  5. package/dist/ai/index.js +153 -4
  6. package/dist/ai/index.js.map +6 -6
  7. package/dist/ai/rag/quality.js +60 -1
  8. package/dist/ai/rag/quality.js.map +3 -3
  9. package/dist/ai/rag/ui.js +113 -1
  10. package/dist/ai/rag/ui.js.map +4 -4
  11. package/dist/ai-client/angular/ai/index.js +111 -0
  12. package/dist/ai-client/react/ai/index.js +141 -7
  13. package/dist/ai-client/vue/ai/index.js +135 -1
  14. package/dist/angular/ai/index.js +112 -1
  15. package/dist/angular/ai/index.js.map +4 -4
  16. package/dist/react/ai/index.js +142 -8
  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/grounding.d.ts +2 -1
  20. package/dist/src/ai/rag/index.d.ts +1 -1
  21. package/dist/src/ai/rag/presentation.d.ts +2 -2
  22. package/dist/src/ai/rag/ui.d.ts +1 -1
  23. package/dist/src/react/ai/useRAG.d.ts +4 -0
  24. package/dist/src/react/ai/useRAGChunkPreview.d.ts +3 -0
  25. package/dist/src/react/ai/useRAGSources.d.ts +1 -0
  26. package/dist/src/svelte/ai/createRAG.d.ts +4 -0
  27. package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +3 -0
  28. package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
  29. package/dist/src/vue/ai/useRAG.d.ts +4 -0
  30. package/dist/src/vue/ai/useRAGChunkPreview.d.ts +3 -0
  31. package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
  32. package/dist/svelte/ai/index.js +149 -3
  33. package/dist/svelte/ai/index.js.map +6 -6
  34. package/dist/types/ai.d.ts +20 -1
  35. package/dist/vue/ai/index.js +136 -2
  36. package/dist/vue/ai/index.js.map +6 -6
  37. package/package.json +1 -1
@@ -354,6 +354,13 @@ var buildGroundingReferenceEvidenceSummary = (reference) => [
354
354
  reference.contextLabel,
355
355
  reference.provenanceLabel
356
356
  ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
357
+ var buildGroundingSectionKey = (reference) => reference.contextLabel ?? reference.locatorLabel ?? reference.label ?? reference.source ?? reference.chunkId;
358
+ var buildGroundingSectionSummaryLine = (reference) => [
359
+ reference.source ?? reference.title ?? reference.chunkId,
360
+ reference.locatorLabel,
361
+ reference.contextLabel,
362
+ reference.provenanceLabel
363
+ ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
357
364
  var buildGroundedAnswerCitationDetail = (reference) => ({
358
365
  contextLabel: reference.contextLabel,
359
366
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
@@ -444,9 +451,61 @@ var buildRAGGroundedAnswer = (content, sources) => {
444
451
  hasCitations,
445
452
  parts,
446
453
  references,
454
+ sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
447
455
  ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
448
456
  };
449
457
  };
458
+ var buildRAGGroundedAnswerSectionSummaries = (references) => {
459
+ const groups = new Map;
460
+ for (const reference of references) {
461
+ const key = buildGroundingSectionKey(reference);
462
+ const existing = groups.get(key);
463
+ if (!existing) {
464
+ groups.set(key, {
465
+ chunkIds: [reference.chunkId],
466
+ contextLabel: reference.contextLabel,
467
+ count: 1,
468
+ key,
469
+ label: key,
470
+ locatorLabel: reference.locatorLabel,
471
+ provenanceLabel: reference.provenanceLabel,
472
+ referenceNumbers: [reference.number],
473
+ references: [reference],
474
+ summary: buildGroundingSectionSummaryLine(reference) || reference.label || reference.chunkId
475
+ });
476
+ continue;
477
+ }
478
+ existing.count += 1;
479
+ if (!existing.chunkIds.includes(reference.chunkId)) {
480
+ existing.chunkIds.push(reference.chunkId);
481
+ }
482
+ if (!existing.referenceNumbers.includes(reference.number)) {
483
+ existing.referenceNumbers.push(reference.number);
484
+ }
485
+ existing.references.push(reference);
486
+ if (!existing.contextLabel && reference.contextLabel) {
487
+ existing.contextLabel = reference.contextLabel;
488
+ }
489
+ if (!existing.locatorLabel && reference.locatorLabel) {
490
+ existing.locatorLabel = reference.locatorLabel;
491
+ }
492
+ if (!existing.provenanceLabel && reference.provenanceLabel) {
493
+ existing.provenanceLabel = reference.provenanceLabel;
494
+ }
495
+ }
496
+ return [...groups.values()].map((group) => ({
497
+ ...group,
498
+ referenceNumbers: [...group.referenceNumbers].sort((left, right) => left - right),
499
+ references: group.references.slice().sort((left, right) => left.number - right.number)
500
+ })).sort((left, right) => {
501
+ const leftFirst = left.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
502
+ const rightFirst = right.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
503
+ if (leftFirst !== rightFirst) {
504
+ return leftFirst - rightFirst;
505
+ }
506
+ return left.label.localeCompare(right.label);
507
+ });
508
+ };
450
509
  var buildRAGGroundingReferences = (sources) => {
451
510
  const citations = buildRAGCitations(sources);
452
511
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
@@ -4801,11 +4860,13 @@ var buildRAGChunkGraph = (chunks) => {
4801
4860
  const existing = sections.get(sectionId);
4802
4861
  if (!existing) {
4803
4862
  sections.set(sectionId, {
4863
+ childSectionIds: [],
4804
4864
  chunkCount: structure.sequence?.sectionChunkCount ?? 1,
4805
4865
  chunkIds: [chunk.chunkId],
4806
4866
  depth: structure.section?.depth,
4807
4867
  id: sectionId,
4808
4868
  kind: structure.section?.kind,
4869
+ leadChunkId: chunk.chunkId,
4809
4870
  path: structure.section?.path,
4810
4871
  title: structure.section?.title
4811
4872
  });
@@ -4828,6 +4889,48 @@ var buildRAGChunkGraph = (chunks) => {
4828
4889
  }
4829
4890
  return left.localeCompare(right);
4830
4891
  });
4892
+ section.leadChunkId = section.chunkIds[0];
4893
+ }
4894
+ const sectionPathIndex = new Map;
4895
+ for (const section of sections.values()) {
4896
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4897
+ if (path && path.length > 0) {
4898
+ sectionPathIndex.set(path.join("\x00"), section);
4899
+ }
4900
+ }
4901
+ for (const section of sections.values()) {
4902
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4903
+ if (!path || path.length < 2) {
4904
+ continue;
4905
+ }
4906
+ const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
4907
+ if (!parent || parent.id === section.id) {
4908
+ continue;
4909
+ }
4910
+ section.parentSectionId = parent.id;
4911
+ if (!parent.childSectionIds.includes(section.id)) {
4912
+ parent.childSectionIds.push(section.id);
4913
+ }
4914
+ if (parent.leadChunkId && section.leadChunkId) {
4915
+ const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
4916
+ if (!edgeKeys.has(parentKey)) {
4917
+ edgeKeys.add(parentKey);
4918
+ edges.push({
4919
+ fromChunkId: section.leadChunkId,
4920
+ relation: "section_parent",
4921
+ toChunkId: parent.leadChunkId
4922
+ });
4923
+ }
4924
+ const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
4925
+ if (!edgeKeys.has(childKey)) {
4926
+ edgeKeys.add(childKey);
4927
+ edges.push({
4928
+ fromChunkId: parent.leadChunkId,
4929
+ relation: "section_child",
4930
+ toChunkId: section.leadChunkId
4931
+ });
4932
+ }
4933
+ }
4831
4934
  }
4832
4935
  nodes.sort((left, right) => {
4833
4936
  const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
@@ -4861,6 +4964,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4861
4964
  if (graph.nodes.length === 0) {
4862
4965
  return {
4863
4966
  activeChunkId,
4967
+ childSections: [],
4968
+ siblingSections: [],
4864
4969
  sectionNodes: []
4865
4970
  };
4866
4971
  }
@@ -4869,13 +4974,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4869
4974
  const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
4870
4975
  const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
4871
4976
  const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
4977
+ const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
4978
+ const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
4979
+ const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
4872
4980
  const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
4873
4981
  return {
4874
4982
  activeChunkId: resolvedActiveChunkId,
4875
4983
  activeNode,
4984
+ childSections,
4876
4985
  nextNode,
4986
+ parentSection,
4877
4987
  previousNode,
4878
4988
  section,
4989
+ siblingSections,
4879
4990
  sectionNodes
4880
4991
  };
4881
4992
  };
@@ -6848,5 +6959,5 @@ export {
6848
6959
  buildRAGEvaluationLeaderboard
6849
6960
  };
6850
6961
 
6851
- //# debugId=C86DB4BD7A51410264756E2164756E21
6962
+ //# debugId=260B815A92E7FE6E64756E2164756E21
6852
6963
  //# sourceMappingURL=index.js.map