@absolutejs/absolute 0.19.0-beta.610 → 0.19.0-beta.612
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 +49 -1
- package/dist/ai/client/index.js.map +3 -3
- package/dist/ai/client/ui.js +49 -1
- package/dist/ai/client/ui.js.map +3 -3
- package/dist/ai/index.js +85 -2
- package/dist/ai/index.js.map +5 -5
- package/dist/ai/rag/ui.js +49 -1
- package/dist/ai/rag/ui.js.map +3 -3
- package/dist/ai-client/angular/ai/index.js +48 -0
- package/dist/ai-client/react/ai/index.js +48 -0
- package/dist/ai-client/vue/ai/index.js +48 -0
- package/dist/angular/ai/index.js +49 -1
- package/dist/angular/ai/index.js.map +3 -3
- package/dist/react/ai/index.js +49 -1
- package/dist/react/ai/index.js.map +3 -3
- package/dist/svelte/ai/index.js +49 -1
- package/dist/svelte/ai/index.js.map +3 -3
- package/dist/types/ai.d.ts +23 -0
- package/dist/vue/ai/index.js +49 -1
- package/dist/vue/ai/index.js.map +3 -3
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -4702,6 +4702,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4702
4702
|
}
|
|
4703
4703
|
const diagnostics = [...sections.values()];
|
|
4704
4704
|
const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
|
|
4705
|
+
const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
|
|
4706
|
+
const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
|
|
4705
4707
|
return diagnostics.map((section) => {
|
|
4706
4708
|
const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
|
|
4707
4709
|
const siblings = siblingPool.filter((entry) => entry.key !== section.key);
|
|
@@ -4718,6 +4720,48 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4718
4720
|
totalScore: entry.totalScore
|
|
4719
4721
|
})).sort((left, right) => right.totalScore - left.totalScore) : [];
|
|
4720
4722
|
const reasons = [];
|
|
4723
|
+
const stageCounts = trace?.steps.map((step) => ({
|
|
4724
|
+
count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
|
|
4725
|
+
stage: step.stage
|
|
4726
|
+
})).filter((entry) => entry.count > 0) ?? [];
|
|
4727
|
+
const stageWeights = stageCounts.map((entry) => {
|
|
4728
|
+
const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
|
|
4729
|
+
const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
4730
|
+
const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4731
|
+
const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4732
|
+
const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
|
|
4733
|
+
const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
4734
|
+
const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
|
|
4735
|
+
const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
|
|
4736
|
+
const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
|
|
4737
|
+
const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
|
|
4738
|
+
const reasons2 = [];
|
|
4739
|
+
if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
|
|
4740
|
+
reasons2.push("rerank_preserved_lead");
|
|
4741
|
+
}
|
|
4742
|
+
if (entry.stage === "finalize" && stageShare >= 0.5) {
|
|
4743
|
+
reasons2.push("final_stage_concentration");
|
|
4744
|
+
}
|
|
4745
|
+
if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
|
|
4746
|
+
reasons2.push("final_stage_dominant_within_parent");
|
|
4747
|
+
}
|
|
4748
|
+
if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
|
|
4749
|
+
reasons2.push("stage_runner_up_pressure");
|
|
4750
|
+
}
|
|
4751
|
+
return {
|
|
4752
|
+
count: entry.count,
|
|
4753
|
+
parentStageShare,
|
|
4754
|
+
parentStageShareGap,
|
|
4755
|
+
reasons: reasons2,
|
|
4756
|
+
stage: entry.stage,
|
|
4757
|
+
stageShare,
|
|
4758
|
+
stageShareGap,
|
|
4759
|
+
strongestSiblingCount: strongestStageSibling?.count,
|
|
4760
|
+
strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
|
|
4761
|
+
};
|
|
4762
|
+
});
|
|
4763
|
+
const firstSeenStage = stageCounts[0]?.stage;
|
|
4764
|
+
const lastSeenStage = stageCounts.at(-1)?.stage;
|
|
4721
4765
|
if (section.bestScore >= strongestBestHit) {
|
|
4722
4766
|
reasons.push("best_hit");
|
|
4723
4767
|
}
|
|
@@ -4750,11 +4794,15 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4750
4794
|
parentShare,
|
|
4751
4795
|
parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
|
|
4752
4796
|
path: section.path,
|
|
4797
|
+
firstSeenStage,
|
|
4798
|
+
lastSeenStage,
|
|
4753
4799
|
retrievalMode: trace?.mode,
|
|
4754
4800
|
reasons,
|
|
4755
4801
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
4756
4802
|
scoreShare,
|
|
4757
4803
|
scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
|
|
4804
|
+
stageCounts,
|
|
4805
|
+
stageWeights,
|
|
4758
4806
|
siblingCount: siblings.length,
|
|
4759
4807
|
siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
|
|
4760
4808
|
sourceCount: section.sourceSet.size,
|
|
@@ -10548,6 +10596,32 @@ var annotateRetrievalChannels = (input) => {
|
|
|
10548
10596
|
};
|
|
10549
10597
|
});
|
|
10550
10598
|
};
|
|
10599
|
+
var buildTraceSectionCounts = (results) => {
|
|
10600
|
+
const sections = new Map;
|
|
10601
|
+
for (const result of results) {
|
|
10602
|
+
const path = Array.isArray(result.metadata?.sectionPath) ? result.metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : [];
|
|
10603
|
+
if (path.length === 0) {
|
|
10604
|
+
continue;
|
|
10605
|
+
}
|
|
10606
|
+
const key = path.join(" > ");
|
|
10607
|
+
const existing = sections.get(key);
|
|
10608
|
+
if (existing) {
|
|
10609
|
+
existing.count += 1;
|
|
10610
|
+
continue;
|
|
10611
|
+
}
|
|
10612
|
+
sections.set(key, {
|
|
10613
|
+
count: 1,
|
|
10614
|
+
key,
|
|
10615
|
+
label: path.at(-1) ?? key
|
|
10616
|
+
});
|
|
10617
|
+
}
|
|
10618
|
+
return [...sections.values()].sort((left, right) => {
|
|
10619
|
+
if (right.count !== left.count) {
|
|
10620
|
+
return right.count - left.count;
|
|
10621
|
+
}
|
|
10622
|
+
return left.key.localeCompare(right.key);
|
|
10623
|
+
});
|
|
10624
|
+
};
|
|
10551
10625
|
var shouldRunVectorRetrieval = (mode) => mode === "vector" || mode === "hybrid";
|
|
10552
10626
|
var shouldRunLexicalRetrieval = (mode, store) => mode === "lexical" || mode === "hybrid" && Boolean(store.queryLexical);
|
|
10553
10627
|
var createRAGCollection = (options) => {
|
|
@@ -10661,6 +10735,7 @@ var createRAGCollection = (options) => {
|
|
|
10661
10735
|
queryCount: searchQueries.length,
|
|
10662
10736
|
topK: candidateTopK
|
|
10663
10737
|
},
|
|
10738
|
+
sectionCounts: buildTraceSectionCounts(vectorResults),
|
|
10664
10739
|
stage: "vector_search"
|
|
10665
10740
|
});
|
|
10666
10741
|
}
|
|
@@ -10673,6 +10748,7 @@ var createRAGCollection = (options) => {
|
|
|
10673
10748
|
queryCount: searchQueries.length,
|
|
10674
10749
|
topK: lexicalTopK
|
|
10675
10750
|
},
|
|
10751
|
+
sectionCounts: buildTraceSectionCounts(lexicalResults),
|
|
10676
10752
|
stage: "lexical_search"
|
|
10677
10753
|
});
|
|
10678
10754
|
}
|
|
@@ -10690,6 +10766,7 @@ var createRAGCollection = (options) => {
|
|
|
10690
10766
|
metadata: {
|
|
10691
10767
|
mode: retrieval.mode
|
|
10692
10768
|
},
|
|
10769
|
+
sectionCounts: buildTraceSectionCounts(results),
|
|
10693
10770
|
stage: "fusion"
|
|
10694
10771
|
});
|
|
10695
10772
|
const rerankInput = {
|
|
@@ -10712,6 +10789,7 @@ var createRAGCollection = (options) => {
|
|
|
10712
10789
|
metadata: {
|
|
10713
10790
|
applied: hasReranker
|
|
10714
10791
|
},
|
|
10792
|
+
sectionCounts: buildTraceSectionCounts(reranked),
|
|
10715
10793
|
stage: "rerank"
|
|
10716
10794
|
});
|
|
10717
10795
|
const diversityAdjusted = retrieval.diversityStrategy === "mmr" ? applyRAGMMRDiversity(reranked, queryVector, retrieval.mmrLambda) : reranked;
|
|
@@ -10723,6 +10801,7 @@ var createRAGCollection = (options) => {
|
|
|
10723
10801
|
applied: queryVector.length > 0 && diversityAdjusted.some((entry) => Array.isArray(entry.embedding)),
|
|
10724
10802
|
mmrLambda: retrieval.mmrLambda
|
|
10725
10803
|
},
|
|
10804
|
+
sectionCounts: buildTraceSectionCounts(diversityAdjusted),
|
|
10726
10805
|
stage: "diversity"
|
|
10727
10806
|
});
|
|
10728
10807
|
}
|
|
@@ -10735,6 +10814,7 @@ var createRAGCollection = (options) => {
|
|
|
10735
10814
|
maxResultsPerSource: retrieval.maxResultsPerSource,
|
|
10736
10815
|
strategy: retrieval.sourceBalanceStrategy
|
|
10737
10816
|
},
|
|
10817
|
+
sectionCounts: buildTraceSectionCounts(diversified),
|
|
10738
10818
|
stage: "source_balance"
|
|
10739
10819
|
});
|
|
10740
10820
|
}
|
|
@@ -10750,6 +10830,7 @@ var createRAGCollection = (options) => {
|
|
|
10750
10830
|
metadata: {
|
|
10751
10831
|
appliedScoreThreshold: false
|
|
10752
10832
|
},
|
|
10833
|
+
sectionCounts: buildTraceSectionCounts(limited),
|
|
10753
10834
|
stage: "finalize"
|
|
10754
10835
|
});
|
|
10755
10836
|
return {
|
|
@@ -10787,6 +10868,7 @@ var createRAGCollection = (options) => {
|
|
|
10787
10868
|
metadata: {
|
|
10788
10869
|
scoreThreshold
|
|
10789
10870
|
},
|
|
10871
|
+
sectionCounts: buildTraceSectionCounts(filtered),
|
|
10790
10872
|
stage: "score_filter"
|
|
10791
10873
|
});
|
|
10792
10874
|
steps.push({
|
|
@@ -10795,6 +10877,7 @@ var createRAGCollection = (options) => {
|
|
|
10795
10877
|
metadata: {
|
|
10796
10878
|
appliedScoreThreshold: true
|
|
10797
10879
|
},
|
|
10880
|
+
sectionCounts: buildTraceSectionCounts(filtered),
|
|
10798
10881
|
stage: "finalize"
|
|
10799
10882
|
});
|
|
10800
10883
|
return {
|
|
@@ -10913,7 +10996,7 @@ var renderSectionDiagnostics = (diagnostics) => {
|
|
|
10913
10996
|
if (diagnostics.length === 0) {
|
|
10914
10997
|
return "";
|
|
10915
10998
|
}
|
|
10916
|
-
return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${escapeHtml2(diagnostic.key)}">` + `<h4>${escapeHtml2(diagnostic.path?.join(" > ") ?? diagnostic.label)}</h4>` + `<p class="rag-search-source">${escapeHtml2(diagnostic.summary)}</p>` + `<ul class="rag-source-labels">` + `<li><strong>Top hit</strong> ${diagnostic.bestScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Average</strong> ${diagnostic.averageScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Sources</strong> ${diagnostic.sourceCount}</li>` + `<li><strong>Channels</strong> vector ${diagnostic.vectorHits} \xB7 lexical ${diagnostic.lexicalHits} \xB7 hybrid ${diagnostic.hybridHits}</li>` + `${diagnostic.retrievalMode ? `<li><strong>Trace mode</strong> ${escapeHtml2(diagnostic.retrievalMode)}</li>` : ""}` + `${diagnostic.rerankApplied !== undefined ? `<li><strong>Rerank</strong> ${diagnostic.rerankApplied ? "applied" : "skipped"}</li>` : ""}` + `${diagnostic.sourceBalanceApplied ? `<li><strong>Source balance</strong> applied</li>` : ""}` + `${diagnostic.scoreThresholdApplied ? `<li><strong>Score threshold</strong> applied</li>` : ""}` + `<li><strong>Reasons</strong> ${escapeHtml2(diagnostic.reasons.join(", ") || "none")}</li>` + `${diagnostic.strongestSiblingLabel ? `<li><strong>Strongest sibling</strong> ${escapeHtml2(diagnostic.strongestSiblingLabel)} (${diagnostic.strongestSiblingScore?.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES) ?? "n/a"})</li>` : ""}` + `${typeof diagnostic.parentShareGap === "number" ? `<li><strong>Parent share gap</strong> ${(diagnostic.parentShareGap * 100).toFixed(0)}%</li>` : ""}` + `</ul>` + `${diagnostic.parentDistribution.length > 0 ? `<ul class="rag-source-labels">${diagnostic.parentDistribution.map((entry) => `<li><strong>${entry.isActive ? "Active section" : "Peer section"}</strong> ${escapeHtml2(entry.label)} \xB7 ${(entry.parentShare * 100).toFixed(0)}% \xB7 ${entry.count} hit${entry.count === 1 ? "" : "s"}</li>`).join("")}</ul>` : ""}` + `</article>`).join("") + `</section>`;
|
|
10999
|
+
return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${escapeHtml2(diagnostic.key)}">` + `<h4>${escapeHtml2(diagnostic.path?.join(" > ") ?? diagnostic.label)}</h4>` + `<p class="rag-search-source">${escapeHtml2(diagnostic.summary)}</p>` + `<ul class="rag-source-labels">` + `<li><strong>Top hit</strong> ${diagnostic.bestScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Average</strong> ${diagnostic.averageScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Sources</strong> ${diagnostic.sourceCount}</li>` + `<li><strong>Channels</strong> vector ${diagnostic.vectorHits} \xB7 lexical ${diagnostic.lexicalHits} \xB7 hybrid ${diagnostic.hybridHits}</li>` + `${diagnostic.stageCounts.length > 0 ? `<li><strong>Stage flow</strong> ${escapeHtml2(diagnostic.stageCounts.map((entry) => `${entry.stage} ${entry.count}`).join(" \u2192 "))}</li>` : ""}` + `${diagnostic.firstSeenStage ? `<li><strong>First seen</strong> ${escapeHtml2(diagnostic.firstSeenStage)}</li>` : ""}` + `${diagnostic.lastSeenStage ? `<li><strong>Last seen</strong> ${escapeHtml2(diagnostic.lastSeenStage)}</li>` : ""}` + `${diagnostic.retrievalMode ? `<li><strong>Trace mode</strong> ${escapeHtml2(diagnostic.retrievalMode)}</li>` : ""}` + `${diagnostic.rerankApplied !== undefined ? `<li><strong>Rerank</strong> ${diagnostic.rerankApplied ? "applied" : "skipped"}</li>` : ""}` + `${diagnostic.sourceBalanceApplied ? `<li><strong>Source balance</strong> applied</li>` : ""}` + `${diagnostic.scoreThresholdApplied ? `<li><strong>Score threshold</strong> applied</li>` : ""}` + `<li><strong>Reasons</strong> ${escapeHtml2(diagnostic.reasons.join(", ") || "none")}</li>` + `${diagnostic.strongestSiblingLabel ? `<li><strong>Strongest sibling</strong> ${escapeHtml2(diagnostic.strongestSiblingLabel)} (${diagnostic.strongestSiblingScore?.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES) ?? "n/a"})</li>` : ""}` + `${typeof diagnostic.parentShareGap === "number" ? `<li><strong>Parent share gap</strong> ${(diagnostic.parentShareGap * 100).toFixed(0)}%</li>` : ""}` + `</ul>` + `${diagnostic.stageWeights.length > 0 ? `<ul class="rag-source-labels">${diagnostic.stageWeights.map((entry) => `<li><strong>${escapeHtml2(entry.stage)}</strong> ${(entry.stageShare * 100).toFixed(0)}% of stage` + `${typeof entry.parentStageShare === "number" ? ` \xB7 ${(entry.parentStageShare * 100).toFixed(0)}% of parent stage` : ""}` + `${typeof entry.stageShareGap === "number" ? ` \xB7 gap ${(entry.stageShareGap * 100).toFixed(0)}%` : ""}` + `${entry.strongestSiblingLabel ? ` \xB7 runner-up ${escapeHtml2(entry.strongestSiblingLabel)}` : ""}` + `${entry.reasons.length > 0 ? ` \xB7 ${escapeHtml2(entry.reasons.join(", "))}` : ""}</li>`).join("")}</ul>` : ""}` + `${diagnostic.parentDistribution.length > 0 ? `<ul class="rag-source-labels">${diagnostic.parentDistribution.map((entry) => `<li><strong>${entry.isActive ? "Active section" : "Peer section"}</strong> ${escapeHtml2(entry.label)} \xB7 ${(entry.parentShare * 100).toFixed(0)}% \xB7 ${entry.count} hit${entry.count === 1 ? "" : "s"}</li>`).join("")}</ul>` : ""}` + `</article>`).join("") + `</section>`;
|
|
10917
11000
|
};
|
|
10918
11001
|
var renderEmptyState = (kind) => {
|
|
10919
11002
|
switch (kind) {
|
|
@@ -22208,5 +22291,5 @@ export {
|
|
|
22208
22291
|
aiChat
|
|
22209
22292
|
};
|
|
22210
22293
|
|
|
22211
|
-
//# debugId=
|
|
22294
|
+
//# debugId=1ADA1065B50387AC64756E2164756E21
|
|
22212
22295
|
//# sourceMappingURL=index.js.map
|