@absolutejs/absolute 0.19.0-beta.609 → 0.19.0-beta.610
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 +244 -21
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +245 -21
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +294 -28
- package/dist/ai/index.js.map +7 -7
- package/dist/ai/rag/quality.js +53 -11
- package/dist/ai/rag/quality.js.map +3 -3
- package/dist/ai/rag/ui.js +245 -21
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +243 -20
- package/dist/ai-client/react/ai/index.js +262 -20
- package/dist/ai-client/vue/ai/index.js +262 -20
- package/dist/angular/ai/index.js +244 -21
- 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 +263 -21
- 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 +8 -1
- package/dist/src/ai/rag/ui.d.ts +1 -1
- package/dist/src/react/ai/useRAG.d.ts +3 -0
- package/dist/src/react/ai/useRAGChunkPreview.d.ts +2 -0
- package/dist/src/react/ai/useRAGSources.d.ts +1 -0
- package/dist/src/svelte/ai/createRAG.d.ts +3 -0
- package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +2 -0
- package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
- package/dist/src/vue/ai/useRAG.d.ts +11 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +10 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
- package/dist/svelte/ai/index.js +263 -21
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +56 -0
- package/dist/vue/ai/index.js +263 -21
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
package/dist/ai/rag/quality.js
CHANGED
|
@@ -341,21 +341,48 @@ var buildExcerpt = (text, maxLength = 160) => {
|
|
|
341
341
|
};
|
|
342
342
|
var selectPreferredExcerpt = (excerpts, sectionChunkCount) => {
|
|
343
343
|
if (!excerpts) {
|
|
344
|
-
return
|
|
344
|
+
return {
|
|
345
|
+
excerpt: "",
|
|
346
|
+
mode: "chunk",
|
|
347
|
+
reason: "single_chunk"
|
|
348
|
+
};
|
|
345
349
|
}
|
|
346
350
|
const chunkExcerpt = excerpts.chunkExcerpt?.trim() ?? "";
|
|
347
351
|
const windowExcerpt = excerpts.windowExcerpt?.trim() ?? "";
|
|
348
352
|
const sectionExcerpt = excerpts.sectionExcerpt?.trim() ?? "";
|
|
349
353
|
if (sectionChunkCount && sectionChunkCount > 1 && chunkExcerpt.length > 0 && chunkExcerpt.length < 72) {
|
|
350
354
|
if (sectionChunkCount <= 3 && sectionExcerpt) {
|
|
351
|
-
return
|
|
355
|
+
return {
|
|
356
|
+
excerpt: sectionExcerpt,
|
|
357
|
+
mode: "section",
|
|
358
|
+
reason: "section_small_enough"
|
|
359
|
+
};
|
|
352
360
|
}
|
|
353
361
|
if (windowExcerpt) {
|
|
354
|
-
return
|
|
362
|
+
return {
|
|
363
|
+
excerpt: windowExcerpt,
|
|
364
|
+
mode: "window",
|
|
365
|
+
reason: "section_too_large_use_window"
|
|
366
|
+
};
|
|
355
367
|
}
|
|
368
|
+
return {
|
|
369
|
+
excerpt: chunkExcerpt,
|
|
370
|
+
mode: "chunk",
|
|
371
|
+
reason: "chunk_too_narrow"
|
|
372
|
+
};
|
|
356
373
|
}
|
|
357
|
-
return
|
|
374
|
+
return {
|
|
375
|
+
excerpt: chunkExcerpt || windowExcerpt || sectionExcerpt,
|
|
376
|
+
mode: "chunk",
|
|
377
|
+
reason: (sectionChunkCount ?? 0) > 1 ? "chunk_too_narrow" : "single_chunk"
|
|
378
|
+
};
|
|
358
379
|
};
|
|
380
|
+
var buildExcerptModeCounts = (references) => references.reduce((counts, reference) => {
|
|
381
|
+
if (reference?.excerptSelection) {
|
|
382
|
+
counts[reference.excerptSelection.mode] += 1;
|
|
383
|
+
}
|
|
384
|
+
return counts;
|
|
385
|
+
}, { chunk: 0, section: 0, window: 0 });
|
|
359
386
|
var buildGroundingChunkExcerpts = (sources, activeChunkId) => {
|
|
360
387
|
if (sources.length === 0) {
|
|
361
388
|
return;
|
|
@@ -411,8 +438,9 @@ var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
|
411
438
|
contextLabel: reference.contextLabel,
|
|
412
439
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
413
440
|
evidenceSummary: buildGroundingReferenceEvidenceSummary(reference),
|
|
414
|
-
excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || reference.excerpt,
|
|
441
|
+
excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || reference.excerpt,
|
|
415
442
|
excerpts: reference.excerpts,
|
|
443
|
+
excerptSelection: reference.excerptSelection,
|
|
416
444
|
label: reference.label,
|
|
417
445
|
locatorLabel: reference.locatorLabel,
|
|
418
446
|
number: reference.number,
|
|
@@ -429,11 +457,14 @@ var buildRAGCitations = (sources) => {
|
|
|
429
457
|
const hasBetterExisting = existing !== undefined && existing.score >= source.score;
|
|
430
458
|
if (hasBetterExisting)
|
|
431
459
|
continue;
|
|
460
|
+
const excerpts = buildGroundingChunkExcerpts(sources, source.chunkId);
|
|
461
|
+
const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(source.metadata?.sectionChunkCount));
|
|
432
462
|
unique.set(key, {
|
|
433
463
|
chunkId: source.chunkId,
|
|
434
464
|
contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
|
|
435
|
-
excerpt:
|
|
436
|
-
excerpts
|
|
465
|
+
excerpt: excerptSelection.excerpt || buildExcerpt(source.text),
|
|
466
|
+
excerpts,
|
|
467
|
+
excerptSelection,
|
|
437
468
|
key,
|
|
438
469
|
label: buildSourceLabel(source),
|
|
439
470
|
locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
|
|
@@ -454,6 +485,7 @@ var buildRAGCitations = (sources) => {
|
|
|
454
485
|
};
|
|
455
486
|
var buildRAGGroundedAnswer = (content, sources) => {
|
|
456
487
|
const references = buildRAGGroundingReferences(sources);
|
|
488
|
+
const sectionSummaries = buildRAGGroundedAnswerSectionSummaries(references);
|
|
457
489
|
const referenceMap = new Map(references.map((reference) => [reference.number, reference]));
|
|
458
490
|
const parts = [];
|
|
459
491
|
const ungroundedReferenceNumbers = new Set;
|
|
@@ -497,10 +529,14 @@ var buildRAGGroundedAnswer = (content, sources) => {
|
|
|
497
529
|
return {
|
|
498
530
|
content,
|
|
499
531
|
coverage,
|
|
532
|
+
excerptModeCounts: buildExcerptModeCounts([
|
|
533
|
+
...references,
|
|
534
|
+
...sectionSummaries
|
|
535
|
+
]),
|
|
500
536
|
hasCitations,
|
|
501
537
|
parts,
|
|
502
538
|
references,
|
|
503
|
-
sectionSummaries
|
|
539
|
+
sectionSummaries,
|
|
504
540
|
ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
|
|
505
541
|
};
|
|
506
542
|
};
|
|
@@ -519,8 +555,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
|
519
555
|
chunkIds: [reference.chunkId],
|
|
520
556
|
contextLabel: reference.contextLabel,
|
|
521
557
|
count: 1,
|
|
522
|
-
excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || excerpts?.sectionExcerpt || reference.excerpt,
|
|
558
|
+
excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || excerpts?.sectionExcerpt || reference.excerpt,
|
|
523
559
|
excerpts,
|
|
560
|
+
excerptSelection: reference.excerptSelection,
|
|
524
561
|
key,
|
|
525
562
|
label: key,
|
|
526
563
|
locatorLabel: reference.locatorLabel,
|
|
@@ -556,6 +593,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
|
|
|
556
593
|
};
|
|
557
594
|
existing.excerpt = reference.excerpts.sectionExcerpt;
|
|
558
595
|
}
|
|
596
|
+
if (!existing.excerptSelection && reference.excerptSelection) {
|
|
597
|
+
existing.excerptSelection = reference.excerptSelection;
|
|
598
|
+
}
|
|
559
599
|
}
|
|
560
600
|
return [...groups.values()].map((group) => ({
|
|
561
601
|
...group,
|
|
@@ -575,11 +615,13 @@ var buildRAGGroundingReferences = (sources) => {
|
|
|
575
615
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
576
616
|
return citations.map((citation) => {
|
|
577
617
|
const excerpts = buildGroundingChunkExcerpts(sources, citation.chunkId);
|
|
618
|
+
const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount));
|
|
578
619
|
return {
|
|
579
620
|
chunkId: citation.chunkId,
|
|
580
621
|
contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
|
|
581
|
-
excerpt:
|
|
622
|
+
excerpt: excerptSelection.excerpt || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
|
|
582
623
|
excerpts,
|
|
624
|
+
excerptSelection,
|
|
583
625
|
label: citation.label,
|
|
584
626
|
locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
|
|
585
627
|
metadata: citation.metadata,
|
|
@@ -3751,5 +3793,5 @@ export {
|
|
|
3751
3793
|
buildRAGAnswerGroundingCaseDifficultyLeaderboard
|
|
3752
3794
|
};
|
|
3753
3795
|
|
|
3754
|
-
//# debugId=
|
|
3796
|
+
//# debugId=40702D5082EC52F464756E2164756E21
|
|
3755
3797
|
//# sourceMappingURL=quality.js.map
|