@absolutejs/absolute 0.19.0-beta.606 → 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.
@@ -243,6 +243,13 @@ var buildGroundingReferenceEvidenceSummary = (reference) => [
243
243
  reference.contextLabel,
244
244
  reference.provenanceLabel
245
245
  ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
246
+ var buildGroundingSectionKey = (reference) => reference.contextLabel ?? reference.locatorLabel ?? reference.label ?? reference.source ?? reference.chunkId;
247
+ var buildGroundingSectionSummaryLine = (reference) => [
248
+ reference.source ?? reference.title ?? reference.chunkId,
249
+ reference.locatorLabel,
250
+ reference.contextLabel,
251
+ reference.provenanceLabel
252
+ ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
246
253
  var buildGroundedAnswerCitationDetail = (reference) => ({
247
254
  contextLabel: reference.contextLabel,
248
255
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
@@ -333,9 +340,61 @@ var buildRAGGroundedAnswer = (content, sources) => {
333
340
  hasCitations,
334
341
  parts,
335
342
  references,
343
+ sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
336
344
  ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
337
345
  };
338
346
  };
347
+ var buildRAGGroundedAnswerSectionSummaries = (references) => {
348
+ const groups = new Map;
349
+ for (const reference of references) {
350
+ const key = buildGroundingSectionKey(reference);
351
+ const existing = groups.get(key);
352
+ if (!existing) {
353
+ groups.set(key, {
354
+ chunkIds: [reference.chunkId],
355
+ contextLabel: reference.contextLabel,
356
+ count: 1,
357
+ key,
358
+ label: key,
359
+ locatorLabel: reference.locatorLabel,
360
+ provenanceLabel: reference.provenanceLabel,
361
+ referenceNumbers: [reference.number],
362
+ references: [reference],
363
+ summary: buildGroundingSectionSummaryLine(reference) || reference.label || reference.chunkId
364
+ });
365
+ continue;
366
+ }
367
+ existing.count += 1;
368
+ if (!existing.chunkIds.includes(reference.chunkId)) {
369
+ existing.chunkIds.push(reference.chunkId);
370
+ }
371
+ if (!existing.referenceNumbers.includes(reference.number)) {
372
+ existing.referenceNumbers.push(reference.number);
373
+ }
374
+ existing.references.push(reference);
375
+ if (!existing.contextLabel && reference.contextLabel) {
376
+ existing.contextLabel = reference.contextLabel;
377
+ }
378
+ if (!existing.locatorLabel && reference.locatorLabel) {
379
+ existing.locatorLabel = reference.locatorLabel;
380
+ }
381
+ if (!existing.provenanceLabel && reference.provenanceLabel) {
382
+ existing.provenanceLabel = reference.provenanceLabel;
383
+ }
384
+ }
385
+ return [...groups.values()].map((group) => ({
386
+ ...group,
387
+ referenceNumbers: [...group.referenceNumbers].sort((left, right) => left - right),
388
+ references: group.references.slice().sort((left, right) => left.number - right.number)
389
+ })).sort((left, right) => {
390
+ const leftFirst = left.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
391
+ const rightFirst = right.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
392
+ if (leftFirst !== rightFirst) {
393
+ return leftFirst - rightFirst;
394
+ }
395
+ return left.label.localeCompare(right.label);
396
+ });
397
+ };
339
398
  var buildRAGGroundingReferences = (sources) => {
340
399
  const citations = buildRAGCitations(sources);
341
400
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
@@ -1975,6 +2034,7 @@ export {
1975
2034
  buildRAGSourceSummaries,
1976
2035
  buildRAGSourceGroups,
1977
2036
  buildRAGGroundingReferences,
2037
+ buildRAGGroundedAnswerSectionSummaries,
1978
2038
  buildRAGGroundedAnswer,
1979
2039
  buildRAGCitationReferenceMap,
1980
2040
  buildRAGChunkPreviewNavigation,
@@ -1984,5 +2044,5 @@ export {
1984
2044
  buildRAGAnswerWorkflowState
1985
2045
  };
1986
2046
 
1987
- //# debugId=946864EEE44A7E8964756E2164756E21
2047
+ //# debugId=2E81BE875BD0169964756E2164756E21
1988
2048
  //# sourceMappingURL=ui.js.map