@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/index.js
CHANGED
|
@@ -5265,6 +5265,10 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5265
5265
|
const vectorHits = channels.includes("vector") ? 1 : 0;
|
|
5266
5266
|
const lexicalHits = channels.includes("lexical") ? 1 : 0;
|
|
5267
5267
|
const hybridHits = isHybrid ? 1 : 0;
|
|
5268
|
+
const queryOrigin = source.metadata?.retrievalQueryOrigin;
|
|
5269
|
+
const primaryHits = queryOrigin === "primary" ? 1 : 0;
|
|
5270
|
+
const transformedHits = queryOrigin === "transformed" ? 1 : 0;
|
|
5271
|
+
const variantHits = queryOrigin === "variant" ? 1 : 0;
|
|
5268
5272
|
if (!existing) {
|
|
5269
5273
|
sections.set(key, {
|
|
5270
5274
|
bestScore: source.score,
|
|
@@ -5275,10 +5279,13 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5275
5279
|
lexicalHits,
|
|
5276
5280
|
parentLabel,
|
|
5277
5281
|
path,
|
|
5282
|
+
primaryHits,
|
|
5278
5283
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
5279
5284
|
topChunkId: source.chunkId,
|
|
5280
5285
|
topSource: source.source,
|
|
5281
5286
|
totalScore: source.score,
|
|
5287
|
+
transformedHits,
|
|
5288
|
+
variantHits,
|
|
5282
5289
|
vectorHits
|
|
5283
5290
|
});
|
|
5284
5291
|
continue;
|
|
@@ -5291,6 +5298,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5291
5298
|
existing.vectorHits += vectorHits;
|
|
5292
5299
|
existing.lexicalHits += lexicalHits;
|
|
5293
5300
|
existing.hybridHits += hybridHits;
|
|
5301
|
+
existing.primaryHits += primaryHits;
|
|
5302
|
+
existing.transformedHits += transformedHits;
|
|
5303
|
+
existing.variantHits += variantHits;
|
|
5294
5304
|
if (source.score > existing.bestScore) {
|
|
5295
5305
|
existing.bestScore = source.score;
|
|
5296
5306
|
existing.topChunkId = source.chunkId;
|
|
@@ -5299,6 +5309,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5299
5309
|
}
|
|
5300
5310
|
const diagnostics = [...sections.values()];
|
|
5301
5311
|
const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
|
|
5312
|
+
const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
|
|
5313
|
+
const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
|
|
5314
|
+
const stageSectionScores = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionScores) && step.sectionScores.length > 0).map((step) => [step.stage, step.sectionScores ?? []]));
|
|
5302
5315
|
return diagnostics.map((section) => {
|
|
5303
5316
|
const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
|
|
5304
5317
|
const siblings = siblingPool.filter((entry) => entry.key !== section.key);
|
|
@@ -5319,8 +5332,103 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5319
5332
|
count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
|
|
5320
5333
|
stage: step.stage
|
|
5321
5334
|
})).filter((entry) => entry.count > 0) ?? [];
|
|
5335
|
+
const stageWeights = stageCounts.map((entry) => {
|
|
5336
|
+
const previousStageEntry = stageCounts[stageCounts.findIndex((candidate) => candidate.stage === entry.stage) - 1];
|
|
5337
|
+
const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
|
|
5338
|
+
const stageScoreEntries = stageSectionScores.get(entry.stage)?.filter((candidate) => candidate.totalScore > 0) ?? [];
|
|
5339
|
+
const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
5340
|
+
const stageScoreTotal = stageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
5341
|
+
const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
5342
|
+
const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
5343
|
+
const siblingStageScoreEntries = stageScoreEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
5344
|
+
const parentStageScoreEntries = stageScoreEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
5345
|
+
const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
|
|
5346
|
+
const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
5347
|
+
const activeStageScore = stageScoreEntries.find((candidate) => candidate.key === section.key)?.totalScore;
|
|
5348
|
+
const strongestStageScoreSibling = siblingStageScoreEntries.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
|
|
5349
|
+
const parentStageScoreTotal = parentStageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
5350
|
+
const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
|
|
5351
|
+
const retentionRate = typeof previousStageEntry?.count === "number" && previousStageEntry.count > 0 ? entry.count / previousStageEntry.count : undefined;
|
|
5352
|
+
const countDelta = typeof previousStageEntry?.count === "number" ? entry.count - previousStageEntry.count : undefined;
|
|
5353
|
+
const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
|
|
5354
|
+
const stageScoreShare = typeof activeStageScore === "number" && stageScoreTotal > 0 ? activeStageScore / stageScoreTotal : undefined;
|
|
5355
|
+
const parentStageScoreShare = typeof activeStageScore === "number" && parentStageScoreTotal > 0 ? activeStageScore / parentStageScoreTotal : undefined;
|
|
5356
|
+
const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
|
|
5357
|
+
const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
|
|
5358
|
+
const stageScoreShareGap = typeof activeStageScore === "number" && stageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / stageScoreTotal - strongestStageScoreSibling.totalScore / stageScoreTotal : undefined;
|
|
5359
|
+
const parentStageScoreShareGap = typeof activeStageScore === "number" && parentStageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / parentStageScoreTotal - strongestStageScoreSibling.totalScore / parentStageScoreTotal : undefined;
|
|
5360
|
+
const reasons2 = [];
|
|
5361
|
+
if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
|
|
5362
|
+
reasons2.push("rerank_preserved_lead");
|
|
5363
|
+
}
|
|
5364
|
+
if (entry.stage === "finalize" && stageShare >= 0.5) {
|
|
5365
|
+
reasons2.push("final_stage_concentration");
|
|
5366
|
+
}
|
|
5367
|
+
if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
|
|
5368
|
+
reasons2.push("final_stage_dominant_within_parent");
|
|
5369
|
+
}
|
|
5370
|
+
if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
|
|
5371
|
+
reasons2.push("stage_runner_up_pressure");
|
|
5372
|
+
}
|
|
5373
|
+
if (typeof countDelta === "number") {
|
|
5374
|
+
if (countDelta > 0) {
|
|
5375
|
+
reasons2.push("stage_expanded");
|
|
5376
|
+
} else if (countDelta < 0) {
|
|
5377
|
+
reasons2.push("stage_narrowed");
|
|
5378
|
+
} else {
|
|
5379
|
+
reasons2.push("stage_held");
|
|
5380
|
+
}
|
|
5381
|
+
}
|
|
5382
|
+
return {
|
|
5383
|
+
count: entry.count,
|
|
5384
|
+
countDelta,
|
|
5385
|
+
parentStageScoreShare,
|
|
5386
|
+
parentStageShare,
|
|
5387
|
+
parentStageShareGap,
|
|
5388
|
+
previousCount: previousStageEntry?.count,
|
|
5389
|
+
previousStage: previousStageEntry?.stage,
|
|
5390
|
+
reasons: reasons2,
|
|
5391
|
+
retentionRate,
|
|
5392
|
+
stage: entry.stage,
|
|
5393
|
+
stageScoreShare,
|
|
5394
|
+
stageScoreShareGap,
|
|
5395
|
+
stageShare,
|
|
5396
|
+
stageShareGap,
|
|
5397
|
+
totalScore: activeStageScore,
|
|
5398
|
+
strongestSiblingCount: strongestStageSibling?.count,
|
|
5399
|
+
strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
|
|
5400
|
+
};
|
|
5401
|
+
});
|
|
5322
5402
|
const firstSeenStage = stageCounts[0]?.stage;
|
|
5323
5403
|
const lastSeenStage = stageCounts.at(-1)?.stage;
|
|
5404
|
+
const peakStageEntry = stageCounts.reduce((highest, entry) => !highest || entry.count > highest.count ? entry : highest, undefined);
|
|
5405
|
+
const finalStageEntry = stageCounts.at(-1);
|
|
5406
|
+
const peakCount = peakStageEntry?.count ?? section.count;
|
|
5407
|
+
const finalCount = finalStageEntry?.count;
|
|
5408
|
+
const finalRetentionRate = typeof finalCount === "number" && peakCount > 0 ? finalCount / peakCount : undefined;
|
|
5409
|
+
const dropFromPeak = typeof finalCount === "number" ? peakCount - finalCount : undefined;
|
|
5410
|
+
const queryAttributionReasons = [];
|
|
5411
|
+
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";
|
|
5412
|
+
if (queryAttributionMode === "primary") {
|
|
5413
|
+
queryAttributionReasons.push("base_query_only");
|
|
5414
|
+
}
|
|
5415
|
+
if (queryAttributionMode === "transformed") {
|
|
5416
|
+
queryAttributionReasons.push("transformed_query_only");
|
|
5417
|
+
queryAttributionReasons.push("transform_introduced");
|
|
5418
|
+
}
|
|
5419
|
+
if (queryAttributionMode === "variant") {
|
|
5420
|
+
queryAttributionReasons.push("variant_only");
|
|
5421
|
+
queryAttributionReasons.push("variant_supported");
|
|
5422
|
+
}
|
|
5423
|
+
if (queryAttributionMode === "mixed") {
|
|
5424
|
+
queryAttributionReasons.push("mixed_query_sources");
|
|
5425
|
+
if (section.variantHits > 0) {
|
|
5426
|
+
queryAttributionReasons.push("variant_supported");
|
|
5427
|
+
}
|
|
5428
|
+
if (section.transformedHits > 0 && section.primaryHits === 0) {
|
|
5429
|
+
queryAttributionReasons.push("transform_introduced");
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5324
5432
|
if (section.bestScore >= strongestBestHit) {
|
|
5325
5433
|
reasons.push("best_hit");
|
|
5326
5434
|
}
|
|
@@ -5354,13 +5462,26 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5354
5462
|
parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
|
|
5355
5463
|
path: section.path,
|
|
5356
5464
|
firstSeenStage,
|
|
5465
|
+
finalCount,
|
|
5466
|
+
finalRetentionRate,
|
|
5357
5467
|
lastSeenStage,
|
|
5468
|
+
dropFromPeak,
|
|
5469
|
+
peakCount,
|
|
5470
|
+
peakStage: peakStageEntry?.stage,
|
|
5471
|
+
queryAttribution: {
|
|
5472
|
+
mode: queryAttributionMode,
|
|
5473
|
+
primaryHits: section.primaryHits,
|
|
5474
|
+
reasons: queryAttributionReasons,
|
|
5475
|
+
transformedHits: section.transformedHits,
|
|
5476
|
+
variantHits: section.variantHits
|
|
5477
|
+
},
|
|
5358
5478
|
retrievalMode: trace?.mode,
|
|
5359
5479
|
reasons,
|
|
5360
5480
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
5361
5481
|
scoreShare,
|
|
5362
5482
|
scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
|
|
5363
5483
|
stageCounts,
|
|
5484
|
+
stageWeights,
|
|
5364
5485
|
siblingCount: siblings.length,
|
|
5365
5486
|
siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
|
|
5366
5487
|
sourceCount: section.sourceSet.size,
|
|
@@ -7315,5 +7436,5 @@ export {
|
|
|
7315
7436
|
buildRAGEvaluationLeaderboard
|
|
7316
7437
|
};
|
|
7317
7438
|
|
|
7318
|
-
//# debugId=
|
|
7439
|
+
//# debugId=7134089E98D0712964756E2164756E21
|
|
7319
7440
|
//# sourceMappingURL=index.js.map
|