@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.
package/dist/ai/rag/ui.js CHANGED
@@ -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);
@@ -1992,6 +2051,7 @@ export {
1992
2051
  buildRAGGroundingProviderOverviewPresentation,
1993
2052
  buildRAGGroundingProviderCaseComparisonPresentations,
1994
2053
  buildRAGGroundingOverviewPresentation,
2054
+ buildRAGGroundedAnswerSectionSummaries,
1995
2055
  buildRAGGroundedAnswer,
1996
2056
  buildRAGEvaluationHistoryRows,
1997
2057
  buildRAGEvaluationHistoryPresentation,
@@ -2015,5 +2075,5 @@ export {
2015
2075
  buildRAGAdminActionPresentation
2016
2076
  };
2017
2077
 
2018
- //# debugId=90BBD34D0B0A271364756E2164756E21
2078
+ //# debugId=C09751511BFD6FA564756E2164756E21
2019
2079
  //# sourceMappingURL=ui.js.map