@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
@@ -79,6 +79,18 @@ export type RAGGroundedAnswerCitationDetail = {
79
79
  evidenceLabel: string;
80
80
  evidenceSummary: string;
81
81
  };
82
+ export type RAGGroundedAnswerSectionSummary = {
83
+ key: string;
84
+ label: string;
85
+ summary: string;
86
+ count: number;
87
+ chunkIds: string[];
88
+ referenceNumbers: number[];
89
+ references: RAGGroundingReference[];
90
+ contextLabel?: string;
91
+ locatorLabel?: string;
92
+ provenanceLabel?: string;
93
+ };
82
94
  export type RAGGroundedAnswerPart = {
83
95
  type: 'text';
84
96
  text: string;
@@ -96,6 +108,7 @@ export type RAGGroundedAnswer = {
96
108
  coverage: 'grounded' | 'partial' | 'ungrounded';
97
109
  parts: RAGGroundedAnswerPart[];
98
110
  references: RAGGroundingReference[];
111
+ sectionSummaries: RAGGroundedAnswerSectionSummary[];
99
112
  ungroundedReferenceNumbers: number[];
100
113
  };
101
114
  export type RAGRetrievedState = {
@@ -453,7 +466,7 @@ export type RAGChunkGraphNode = {
453
466
  export type RAGChunkGraphEdge = {
454
467
  fromChunkId: string;
455
468
  toChunkId: string;
456
- relation: 'previous' | 'next';
469
+ relation: 'previous' | 'next' | 'section_parent' | 'section_child';
457
470
  };
458
471
  export type RAGChunkGraphSectionGroup = {
459
472
  id: string;
@@ -463,6 +476,9 @@ export type RAGChunkGraphSectionGroup = {
463
476
  kind?: 'markdown_heading' | 'html_heading';
464
477
  chunkIds: string[];
465
478
  chunkCount: number;
479
+ leadChunkId?: string;
480
+ parentSectionId?: string;
481
+ childSectionIds: string[];
466
482
  };
467
483
  export type RAGChunkGraph = {
468
484
  nodes: RAGChunkGraphNode[];
@@ -475,6 +491,9 @@ export type RAGChunkGraphNavigation = {
475
491
  previousNode?: RAGChunkGraphNode;
476
492
  nextNode?: RAGChunkGraphNode;
477
493
  section?: RAGChunkGraphSectionGroup;
494
+ parentSection?: RAGChunkGraphSectionGroup;
495
+ childSections: RAGChunkGraphSectionGroup[];
496
+ siblingSections: RAGChunkGraphSectionGroup[];
478
497
  sectionNodes: RAGChunkGraphNode[];
479
498
  };
480
499
  export type RAGBackendDescriptor = {
@@ -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);
@@ -4204,11 +4263,13 @@ var buildRAGChunkGraph = (chunks) => {
4204
4263
  const existing = sections.get(sectionId);
4205
4264
  if (!existing) {
4206
4265
  sections.set(sectionId, {
4266
+ childSectionIds: [],
4207
4267
  chunkCount: structure.sequence?.sectionChunkCount ?? 1,
4208
4268
  chunkIds: [chunk.chunkId],
4209
4269
  depth: structure.section?.depth,
4210
4270
  id: sectionId,
4211
4271
  kind: structure.section?.kind,
4272
+ leadChunkId: chunk.chunkId,
4212
4273
  path: structure.section?.path,
4213
4274
  title: structure.section?.title
4214
4275
  });
@@ -4231,6 +4292,48 @@ var buildRAGChunkGraph = (chunks) => {
4231
4292
  }
4232
4293
  return left.localeCompare(right);
4233
4294
  });
4295
+ section.leadChunkId = section.chunkIds[0];
4296
+ }
4297
+ const sectionPathIndex = new Map;
4298
+ for (const section of sections.values()) {
4299
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4300
+ if (path && path.length > 0) {
4301
+ sectionPathIndex.set(path.join("\x00"), section);
4302
+ }
4303
+ }
4304
+ for (const section of sections.values()) {
4305
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4306
+ if (!path || path.length < 2) {
4307
+ continue;
4308
+ }
4309
+ const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
4310
+ if (!parent || parent.id === section.id) {
4311
+ continue;
4312
+ }
4313
+ section.parentSectionId = parent.id;
4314
+ if (!parent.childSectionIds.includes(section.id)) {
4315
+ parent.childSectionIds.push(section.id);
4316
+ }
4317
+ if (parent.leadChunkId && section.leadChunkId) {
4318
+ const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
4319
+ if (!edgeKeys.has(parentKey)) {
4320
+ edgeKeys.add(parentKey);
4321
+ edges.push({
4322
+ fromChunkId: section.leadChunkId,
4323
+ relation: "section_parent",
4324
+ toChunkId: parent.leadChunkId
4325
+ });
4326
+ }
4327
+ const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
4328
+ if (!edgeKeys.has(childKey)) {
4329
+ edgeKeys.add(childKey);
4330
+ edges.push({
4331
+ fromChunkId: parent.leadChunkId,
4332
+ relation: "section_child",
4333
+ toChunkId: section.leadChunkId
4334
+ });
4335
+ }
4336
+ }
4234
4337
  }
4235
4338
  nodes.sort((left, right) => {
4236
4339
  const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
@@ -4264,6 +4367,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4264
4367
  if (graph.nodes.length === 0) {
4265
4368
  return {
4266
4369
  activeChunkId,
4370
+ childSections: [],
4371
+ siblingSections: [],
4267
4372
  sectionNodes: []
4268
4373
  };
4269
4374
  }
@@ -4272,13 +4377,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4272
4377
  const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
4273
4378
  const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
4274
4379
  const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
4380
+ const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
4381
+ const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
4382
+ const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
4275
4383
  const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
4276
4384
  return {
4277
4385
  activeChunkId: resolvedActiveChunkId,
4278
4386
  activeNode,
4387
+ childSections,
4279
4388
  nextNode,
4389
+ parentSection,
4280
4390
  previousNode,
4281
4391
  section,
4392
+ siblingSections,
4282
4393
  sectionNodes
4283
4394
  };
4284
4395
  };
@@ -6798,6 +6909,24 @@ var useRAGChunkPreview = (path) => {
6798
6909
  const selectChunk = (id) => {
6799
6910
  activeChunkId.value = id;
6800
6911
  };
6912
+ const selectParentSection = () => {
6913
+ const leadChunkId = navigation.value?.parentSection?.leadChunkId;
6914
+ if (leadChunkId) {
6915
+ activeChunkId.value = leadChunkId;
6916
+ }
6917
+ };
6918
+ const selectChildSection = (sectionId) => {
6919
+ const leadChunkId = navigation.value?.childSections.find((section) => section.id === sectionId)?.leadChunkId;
6920
+ if (leadChunkId) {
6921
+ activeChunkId.value = leadChunkId;
6922
+ }
6923
+ };
6924
+ const selectSiblingSection = (sectionId) => {
6925
+ const leadChunkId = navigation.value?.siblingSections.find((section) => section.id === sectionId)?.leadChunkId;
6926
+ if (leadChunkId) {
6927
+ activeChunkId.value = leadChunkId;
6928
+ }
6929
+ };
6801
6930
  return {
6802
6931
  activeChunkId,
6803
6932
  clear,
@@ -6807,7 +6936,10 @@ var useRAGChunkPreview = (path) => {
6807
6936
  isLoading,
6808
6937
  navigation,
6809
6938
  preview,
6810
- selectChunk
6939
+ selectChildSection,
6940
+ selectChunk,
6941
+ selectParentSection,
6942
+ selectSiblingSection
6811
6943
  };
6812
6944
  };
6813
6945
  // src/vue/ai/useRAG.ts
@@ -7379,11 +7511,13 @@ var useRAGSources = (messages) => {
7379
7511
  const chunkGraph = computed5(() => buildRAGChunkGraph(sources.value));
7380
7512
  const citationReferenceMap = computed5(() => buildRAGCitationReferenceMap(sourceSummaries.value.flatMap((summary) => summary.citations)));
7381
7513
  const hasSources = computed5(() => sources.value.length > 0);
7514
+ const navigationForChunk = (chunkId) => buildRAGChunkGraphNavigation(chunkGraph.value, chunkId ?? undefined);
7382
7515
  return {
7383
7516
  citationReferenceMap,
7384
7517
  chunkGraph,
7385
7518
  hasSources,
7386
7519
  latestAssistantMessage,
7520
+ navigationForChunk,
7387
7521
  sourceGroups,
7388
7522
  sources,
7389
7523
  sourceSummaries
@@ -7561,5 +7695,5 @@ export {
7561
7695
  AIStreamKey
7562
7696
  };
7563
7697
 
7564
- //# debugId=8B2F93A7DA0F41AD64756E2164756E21
7698
+ //# debugId=6508AB216758DFE664756E2164756E21
7565
7699
  //# sourceMappingURL=index.js.map