@absolutejs/absolute 0.19.0-beta.611 → 0.19.0-beta.613
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 +122 -1
- package/dist/ai/client/index.js.map +3 -3
- package/dist/ai/client/ui.js +122 -1
- package/dist/ai/client/ui.js.map +3 -3
- package/dist/ai/index.js +188 -8
- package/dist/ai/index.js.map +5 -5
- package/dist/ai/rag/ui.js +122 -1
- package/dist/ai/rag/ui.js.map +3 -3
- package/dist/ai-client/angular/ai/index.js +121 -0
- package/dist/ai-client/react/ai/index.js +121 -0
- package/dist/ai-client/vue/ai/index.js +121 -0
- package/dist/angular/ai/index.js +122 -1
- package/dist/angular/ai/index.js.map +3 -3
- package/dist/react/ai/index.js +122 -1
- package/dist/react/ai/index.js.map +3 -3
- package/dist/svelte/ai/index.js +122 -1
- package/dist/svelte/ai/index.js.map +3 -3
- package/dist/types/ai.d.ts +39 -0
- package/dist/vue/ai/index.js +122 -1
- package/dist/vue/ai/index.js.map +3 -3
- package/package.json +7 -7
package/dist/ai/client/ui.js
CHANGED
|
@@ -1486,6 +1486,10 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1486
1486
|
const vectorHits = channels.includes("vector") ? 1 : 0;
|
|
1487
1487
|
const lexicalHits = channels.includes("lexical") ? 1 : 0;
|
|
1488
1488
|
const hybridHits = isHybrid ? 1 : 0;
|
|
1489
|
+
const queryOrigin = source.metadata?.retrievalQueryOrigin;
|
|
1490
|
+
const primaryHits = queryOrigin === "primary" ? 1 : 0;
|
|
1491
|
+
const transformedHits = queryOrigin === "transformed" ? 1 : 0;
|
|
1492
|
+
const variantHits = queryOrigin === "variant" ? 1 : 0;
|
|
1489
1493
|
if (!existing) {
|
|
1490
1494
|
sections.set(key, {
|
|
1491
1495
|
bestScore: source.score,
|
|
@@ -1496,10 +1500,13 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1496
1500
|
lexicalHits,
|
|
1497
1501
|
parentLabel,
|
|
1498
1502
|
path,
|
|
1503
|
+
primaryHits,
|
|
1499
1504
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
1500
1505
|
topChunkId: source.chunkId,
|
|
1501
1506
|
topSource: source.source,
|
|
1502
1507
|
totalScore: source.score,
|
|
1508
|
+
transformedHits,
|
|
1509
|
+
variantHits,
|
|
1503
1510
|
vectorHits
|
|
1504
1511
|
});
|
|
1505
1512
|
continue;
|
|
@@ -1512,6 +1519,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1512
1519
|
existing.vectorHits += vectorHits;
|
|
1513
1520
|
existing.lexicalHits += lexicalHits;
|
|
1514
1521
|
existing.hybridHits += hybridHits;
|
|
1522
|
+
existing.primaryHits += primaryHits;
|
|
1523
|
+
existing.transformedHits += transformedHits;
|
|
1524
|
+
existing.variantHits += variantHits;
|
|
1515
1525
|
if (source.score > existing.bestScore) {
|
|
1516
1526
|
existing.bestScore = source.score;
|
|
1517
1527
|
existing.topChunkId = source.chunkId;
|
|
@@ -1520,6 +1530,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1520
1530
|
}
|
|
1521
1531
|
const diagnostics = [...sections.values()];
|
|
1522
1532
|
const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
|
|
1533
|
+
const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
|
|
1534
|
+
const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
|
|
1535
|
+
const stageSectionScores = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionScores) && step.sectionScores.length > 0).map((step) => [step.stage, step.sectionScores ?? []]));
|
|
1523
1536
|
return diagnostics.map((section) => {
|
|
1524
1537
|
const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
|
|
1525
1538
|
const siblings = siblingPool.filter((entry) => entry.key !== section.key);
|
|
@@ -1540,8 +1553,103 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1540
1553
|
count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
|
|
1541
1554
|
stage: step.stage
|
|
1542
1555
|
})).filter((entry) => entry.count > 0) ?? [];
|
|
1556
|
+
const stageWeights = stageCounts.map((entry) => {
|
|
1557
|
+
const previousStageEntry = stageCounts[stageCounts.findIndex((candidate) => candidate.stage === entry.stage) - 1];
|
|
1558
|
+
const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
|
|
1559
|
+
const stageScoreEntries = stageSectionScores.get(entry.stage)?.filter((candidate) => candidate.totalScore > 0) ?? [];
|
|
1560
|
+
const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
1561
|
+
const stageScoreTotal = stageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
1562
|
+
const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
1563
|
+
const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
1564
|
+
const siblingStageScoreEntries = stageScoreEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
1565
|
+
const parentStageScoreEntries = stageScoreEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
1566
|
+
const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
|
|
1567
|
+
const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
1568
|
+
const activeStageScore = stageScoreEntries.find((candidate) => candidate.key === section.key)?.totalScore;
|
|
1569
|
+
const strongestStageScoreSibling = siblingStageScoreEntries.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
|
|
1570
|
+
const parentStageScoreTotal = parentStageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
1571
|
+
const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
|
|
1572
|
+
const retentionRate = typeof previousStageEntry?.count === "number" && previousStageEntry.count > 0 ? entry.count / previousStageEntry.count : undefined;
|
|
1573
|
+
const countDelta = typeof previousStageEntry?.count === "number" ? entry.count - previousStageEntry.count : undefined;
|
|
1574
|
+
const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
|
|
1575
|
+
const stageScoreShare = typeof activeStageScore === "number" && stageScoreTotal > 0 ? activeStageScore / stageScoreTotal : undefined;
|
|
1576
|
+
const parentStageScoreShare = typeof activeStageScore === "number" && parentStageScoreTotal > 0 ? activeStageScore / parentStageScoreTotal : undefined;
|
|
1577
|
+
const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
|
|
1578
|
+
const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
|
|
1579
|
+
const stageScoreShareGap = typeof activeStageScore === "number" && stageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / stageScoreTotal - strongestStageScoreSibling.totalScore / stageScoreTotal : undefined;
|
|
1580
|
+
const parentStageScoreShareGap = typeof activeStageScore === "number" && parentStageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / parentStageScoreTotal - strongestStageScoreSibling.totalScore / parentStageScoreTotal : undefined;
|
|
1581
|
+
const reasons2 = [];
|
|
1582
|
+
if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
|
|
1583
|
+
reasons2.push("rerank_preserved_lead");
|
|
1584
|
+
}
|
|
1585
|
+
if (entry.stage === "finalize" && stageShare >= 0.5) {
|
|
1586
|
+
reasons2.push("final_stage_concentration");
|
|
1587
|
+
}
|
|
1588
|
+
if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
|
|
1589
|
+
reasons2.push("final_stage_dominant_within_parent");
|
|
1590
|
+
}
|
|
1591
|
+
if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
|
|
1592
|
+
reasons2.push("stage_runner_up_pressure");
|
|
1593
|
+
}
|
|
1594
|
+
if (typeof countDelta === "number") {
|
|
1595
|
+
if (countDelta > 0) {
|
|
1596
|
+
reasons2.push("stage_expanded");
|
|
1597
|
+
} else if (countDelta < 0) {
|
|
1598
|
+
reasons2.push("stage_narrowed");
|
|
1599
|
+
} else {
|
|
1600
|
+
reasons2.push("stage_held");
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return {
|
|
1604
|
+
count: entry.count,
|
|
1605
|
+
countDelta,
|
|
1606
|
+
parentStageScoreShare,
|
|
1607
|
+
parentStageShare,
|
|
1608
|
+
parentStageShareGap,
|
|
1609
|
+
previousCount: previousStageEntry?.count,
|
|
1610
|
+
previousStage: previousStageEntry?.stage,
|
|
1611
|
+
reasons: reasons2,
|
|
1612
|
+
retentionRate,
|
|
1613
|
+
stage: entry.stage,
|
|
1614
|
+
stageScoreShare,
|
|
1615
|
+
stageScoreShareGap,
|
|
1616
|
+
stageShare,
|
|
1617
|
+
stageShareGap,
|
|
1618
|
+
totalScore: activeStageScore,
|
|
1619
|
+
strongestSiblingCount: strongestStageSibling?.count,
|
|
1620
|
+
strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
|
|
1621
|
+
};
|
|
1622
|
+
});
|
|
1543
1623
|
const firstSeenStage = stageCounts[0]?.stage;
|
|
1544
1624
|
const lastSeenStage = stageCounts.at(-1)?.stage;
|
|
1625
|
+
const peakStageEntry = stageCounts.reduce((highest, entry) => !highest || entry.count > highest.count ? entry : highest, undefined);
|
|
1626
|
+
const finalStageEntry = stageCounts.at(-1);
|
|
1627
|
+
const peakCount = peakStageEntry?.count ?? section.count;
|
|
1628
|
+
const finalCount = finalStageEntry?.count;
|
|
1629
|
+
const finalRetentionRate = typeof finalCount === "number" && peakCount > 0 ? finalCount / peakCount : undefined;
|
|
1630
|
+
const dropFromPeak = typeof finalCount === "number" ? peakCount - finalCount : undefined;
|
|
1631
|
+
const queryAttributionReasons = [];
|
|
1632
|
+
const queryAttributionMode = section.primaryHits > 0 && section.transformedHits === 0 && section.variantHits === 0 ? "primary" : section.transformedHits > 0 && section.primaryHits === 0 && section.variantHits === 0 ? "transformed" : section.variantHits > 0 && section.primaryHits === 0 && section.transformedHits === 0 ? "variant" : "mixed";
|
|
1633
|
+
if (queryAttributionMode === "primary") {
|
|
1634
|
+
queryAttributionReasons.push("base_query_only");
|
|
1635
|
+
}
|
|
1636
|
+
if (queryAttributionMode === "transformed") {
|
|
1637
|
+
queryAttributionReasons.push("transformed_query_only");
|
|
1638
|
+
queryAttributionReasons.push("transform_introduced");
|
|
1639
|
+
}
|
|
1640
|
+
if (queryAttributionMode === "variant") {
|
|
1641
|
+
queryAttributionReasons.push("variant_only");
|
|
1642
|
+
queryAttributionReasons.push("variant_supported");
|
|
1643
|
+
}
|
|
1644
|
+
if (queryAttributionMode === "mixed") {
|
|
1645
|
+
queryAttributionReasons.push("mixed_query_sources");
|
|
1646
|
+
if (section.variantHits > 0) {
|
|
1647
|
+
queryAttributionReasons.push("variant_supported");
|
|
1648
|
+
}
|
|
1649
|
+
if (section.transformedHits > 0 && section.primaryHits === 0) {
|
|
1650
|
+
queryAttributionReasons.push("transform_introduced");
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1545
1653
|
if (section.bestScore >= strongestBestHit) {
|
|
1546
1654
|
reasons.push("best_hit");
|
|
1547
1655
|
}
|
|
@@ -1575,13 +1683,26 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1575
1683
|
parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
|
|
1576
1684
|
path: section.path,
|
|
1577
1685
|
firstSeenStage,
|
|
1686
|
+
finalCount,
|
|
1687
|
+
finalRetentionRate,
|
|
1578
1688
|
lastSeenStage,
|
|
1689
|
+
dropFromPeak,
|
|
1690
|
+
peakCount,
|
|
1691
|
+
peakStage: peakStageEntry?.stage,
|
|
1692
|
+
queryAttribution: {
|
|
1693
|
+
mode: queryAttributionMode,
|
|
1694
|
+
primaryHits: section.primaryHits,
|
|
1695
|
+
reasons: queryAttributionReasons,
|
|
1696
|
+
transformedHits: section.transformedHits,
|
|
1697
|
+
variantHits: section.variantHits
|
|
1698
|
+
},
|
|
1579
1699
|
retrievalMode: trace?.mode,
|
|
1580
1700
|
reasons,
|
|
1581
1701
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
1582
1702
|
scoreShare,
|
|
1583
1703
|
scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
|
|
1584
1704
|
stageCounts,
|
|
1705
|
+
stageWeights,
|
|
1585
1706
|
siblingCount: siblings.length,
|
|
1586
1707
|
siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
|
|
1587
1708
|
sourceCount: section.sourceSet.size,
|
|
@@ -2402,5 +2523,5 @@ export {
|
|
|
2402
2523
|
buildRAGAnswerWorkflowState
|
|
2403
2524
|
};
|
|
2404
2525
|
|
|
2405
|
-
//# debugId=
|
|
2526
|
+
//# debugId=9E9A29574772A56C64756E2164756E21
|
|
2406
2527
|
//# sourceMappingURL=ui.js.map
|