@absolutejs/absolute 0.19.0-beta.607 → 0.19.0-beta.609
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/client/index.js +142 -18
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +143 -18
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +371 -28
- package/dist/ai/index.js.map +7 -7
- package/dist/ai/rag/quality.js +92 -16
- package/dist/ai/rag/quality.js.map +3 -3
- package/dist/ai/rag/ui.js +143 -18
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +141 -17
- package/dist/ai-client/react/ai/index.js +141 -17
- package/dist/ai-client/vue/ai/index.js +141 -17
- package/dist/angular/ai/index.js +142 -18
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/server.js +2 -2
- package/dist/angular/server.js.map +1 -1
- package/dist/build.js +2 -2
- package/dist/build.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/ai/index.js +142 -18
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ui.d.ts +1 -1
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/presentation.d.ts +4 -1
- package/dist/src/ai/rag/ui.d.ts +1 -1
- package/dist/src/vue/ai/useRAG.d.ts +14 -4
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +12 -2
- package/dist/src/vue/ai/useRAGSearch.d.ts +2 -2
- package/dist/svelte/ai/index.js +142 -18
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +15 -2
- package/dist/vue/ai/index.js +142 -18
- package/dist/vue/ai/index.js.map +5 -5
- package/package.json +1 -1
package/dist/ai/rag/quality.js
CHANGED
|
@@ -339,6 +339,60 @@ var buildExcerpt = (text, maxLength = 160) => {
|
|
|
339
339
|
}
|
|
340
340
|
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
341
341
|
};
|
|
342
|
+
var selectPreferredExcerpt = (excerpts, sectionChunkCount) => {
|
|
343
|
+
if (!excerpts) {
|
|
344
|
+
return "";
|
|
345
|
+
}
|
|
346
|
+
const chunkExcerpt = excerpts.chunkExcerpt?.trim() ?? "";
|
|
347
|
+
const windowExcerpt = excerpts.windowExcerpt?.trim() ?? "";
|
|
348
|
+
const sectionExcerpt = excerpts.sectionExcerpt?.trim() ?? "";
|
|
349
|
+
if (sectionChunkCount && sectionChunkCount > 1 && chunkExcerpt.length > 0 && chunkExcerpt.length < 72) {
|
|
350
|
+
if (sectionChunkCount <= 3 && sectionExcerpt) {
|
|
351
|
+
return sectionExcerpt;
|
|
352
|
+
}
|
|
353
|
+
if (windowExcerpt) {
|
|
354
|
+
return windowExcerpt;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return chunkExcerpt || windowExcerpt || sectionExcerpt;
|
|
358
|
+
};
|
|
359
|
+
var buildGroundingChunkExcerpts = (sources, activeChunkId) => {
|
|
360
|
+
if (sources.length === 0) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const activeSource = (activeChunkId ? sources.find((source) => source.chunkId === activeChunkId) : undefined) ?? sources[0];
|
|
364
|
+
if (!activeSource) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const chunkMap = new Map(sources.map((source) => [source.chunkId, source]));
|
|
368
|
+
const activeMetadata = activeSource.metadata ?? {};
|
|
369
|
+
const previousChunkId = getContextString(activeMetadata.previousChunkId);
|
|
370
|
+
const nextChunkId = getContextString(activeMetadata.nextChunkId);
|
|
371
|
+
const sectionChunkId = getContextString(activeMetadata.sectionChunkId);
|
|
372
|
+
const sectionSources = sectionChunkId ? sources.filter((source) => getContextString(source.metadata?.sectionChunkId) === sectionChunkId).sort((left, right) => {
|
|
373
|
+
const leftIndex = getContextNumber(left.metadata?.sectionChunkIndex) ?? Number.MAX_SAFE_INTEGER;
|
|
374
|
+
const rightIndex = getContextNumber(right.metadata?.sectionChunkIndex) ?? Number.MAX_SAFE_INTEGER;
|
|
375
|
+
if (leftIndex !== rightIndex) {
|
|
376
|
+
return leftIndex - rightIndex;
|
|
377
|
+
}
|
|
378
|
+
return left.chunkId.localeCompare(right.chunkId);
|
|
379
|
+
}) : [activeSource];
|
|
380
|
+
const collectText = (chunkIds) => chunkIds.map((chunkId) => chunkMap.get(chunkId)?.text).filter((text) => typeof text === "string").join(`
|
|
381
|
+
|
|
382
|
+
`);
|
|
383
|
+
const orderedWindowIds = [
|
|
384
|
+
previousChunkId,
|
|
385
|
+
activeSource.chunkId,
|
|
386
|
+
nextChunkId
|
|
387
|
+
].filter((chunkId, index, values) => Boolean(chunkId) && values.indexOf(chunkId) === index);
|
|
388
|
+
return {
|
|
389
|
+
chunkExcerpt: buildExcerpt(activeSource.text, 160),
|
|
390
|
+
sectionExcerpt: buildExcerpt(sectionSources.map((source) => source.text).join(`
|
|
391
|
+
|
|
392
|
+
`), 320),
|
|
393
|
+
windowExcerpt: buildExcerpt(collectText(orderedWindowIds), 240)
|
|
394
|
+
};
|
|
395
|
+
};
|
|
342
396
|
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 ");
|
|
343
397
|
var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
344
398
|
reference.source ?? reference.title ?? reference.chunkId,
|
|
@@ -357,7 +411,8 @@ var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
|
357
411
|
contextLabel: reference.contextLabel,
|
|
358
412
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
359
413
|
evidenceSummary: buildGroundingReferenceEvidenceSummary(reference),
|
|
360
|
-
excerpt: reference.excerpt,
|
|
414
|
+
excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || reference.excerpt,
|
|
415
|
+
excerpts: reference.excerpts,
|
|
361
416
|
label: reference.label,
|
|
362
417
|
locatorLabel: reference.locatorLabel,
|
|
363
418
|
number: reference.number,
|
|
@@ -377,6 +432,8 @@ var buildRAGCitations = (sources) => {
|
|
|
377
432
|
unique.set(key, {
|
|
378
433
|
chunkId: source.chunkId,
|
|
379
434
|
contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
|
|
435
|
+
excerpt: selectPreferredExcerpt(buildGroundingChunkExcerpts(sources, source.chunkId), getContextNumber(source.metadata?.sectionChunkCount)) || buildExcerpt(source.text),
|
|
436
|
+
excerpts: buildGroundingChunkExcerpts(sources, source.chunkId),
|
|
380
437
|
key,
|
|
381
438
|
label: buildSourceLabel(source),
|
|
382
439
|
locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
|
|
@@ -453,10 +510,17 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
|
453
510
|
const key = buildGroundingSectionKey(reference);
|
|
454
511
|
const existing = groups.get(key);
|
|
455
512
|
if (!existing) {
|
|
513
|
+
const excerpts = reference.excerpts ? {
|
|
514
|
+
chunkExcerpt: reference.excerpts.chunkExcerpt,
|
|
515
|
+
sectionExcerpt: reference.excerpts.sectionExcerpt,
|
|
516
|
+
windowExcerpt: reference.excerpts.windowExcerpt
|
|
517
|
+
} : undefined;
|
|
456
518
|
groups.set(key, {
|
|
457
519
|
chunkIds: [reference.chunkId],
|
|
458
520
|
contextLabel: reference.contextLabel,
|
|
459
521
|
count: 1,
|
|
522
|
+
excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || excerpts?.sectionExcerpt || reference.excerpt,
|
|
523
|
+
excerpts,
|
|
460
524
|
key,
|
|
461
525
|
label: key,
|
|
462
526
|
locatorLabel: reference.locatorLabel,
|
|
@@ -484,6 +548,14 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
|
484
548
|
if (!existing.provenanceLabel && reference.provenanceLabel) {
|
|
485
549
|
existing.provenanceLabel = reference.provenanceLabel;
|
|
486
550
|
}
|
|
551
|
+
if (!existing.excerpts && reference.excerpts) {
|
|
552
|
+
existing.excerpts = {
|
|
553
|
+
chunkExcerpt: reference.excerpts.chunkExcerpt,
|
|
554
|
+
sectionExcerpt: reference.excerpts.sectionExcerpt,
|
|
555
|
+
windowExcerpt: reference.excerpts.windowExcerpt
|
|
556
|
+
};
|
|
557
|
+
existing.excerpt = reference.excerpts.sectionExcerpt;
|
|
558
|
+
}
|
|
487
559
|
}
|
|
488
560
|
return [...groups.values()].map((group) => ({
|
|
489
561
|
...group,
|
|
@@ -501,20 +573,24 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
|
501
573
|
var buildRAGGroundingReferences = (sources) => {
|
|
502
574
|
const citations = buildRAGCitations(sources);
|
|
503
575
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
504
|
-
return citations.map((citation) =>
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
576
|
+
return citations.map((citation) => {
|
|
577
|
+
const excerpts = buildGroundingChunkExcerpts(sources, citation.chunkId);
|
|
578
|
+
return {
|
|
579
|
+
chunkId: citation.chunkId,
|
|
580
|
+
contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
|
|
581
|
+
excerpt: selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount)) || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
|
|
582
|
+
excerpts,
|
|
583
|
+
label: citation.label,
|
|
584
|
+
locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
|
|
585
|
+
metadata: citation.metadata,
|
|
586
|
+
number: citationReferenceMap[citation.chunkId] ?? 0,
|
|
587
|
+
provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
|
|
588
|
+
score: citation.score,
|
|
589
|
+
source: citation.source,
|
|
590
|
+
text: citation.text,
|
|
591
|
+
title: citation.title
|
|
592
|
+
};
|
|
593
|
+
});
|
|
518
594
|
};
|
|
519
595
|
|
|
520
596
|
// src/ai/rag/quality.ts
|
|
@@ -3675,5 +3751,5 @@ export {
|
|
|
3675
3751
|
buildRAGAnswerGroundingCaseDifficultyLeaderboard
|
|
3676
3752
|
};
|
|
3677
3753
|
|
|
3678
|
-
//# debugId=
|
|
3754
|
+
//# debugId=052710711C1D68E964756E2164756E21
|
|
3679
3755
|
//# sourceMappingURL=quality.js.map
|