@absolutejs/absolute 0.19.0-beta.612 → 0.19.0-beta.614
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 +83 -1
- package/dist/ai/client/index.js.map +3 -3
- package/dist/ai/client/ui.js +83 -1
- package/dist/ai/client/ui.js.map +3 -3
- package/dist/ai/index.js +160 -11
- package/dist/ai/index.js.map +5 -5
- package/dist/ai/rag/ui.js +83 -1
- package/dist/ai/rag/ui.js.map +3 -3
- package/dist/ai-client/angular/ai/index.js +82 -0
- package/dist/ai-client/react/ai/index.js +82 -0
- package/dist/ai-client/vue/ai/index.js +82 -0
- package/dist/angular/ai/index.js +83 -1
- package/dist/angular/ai/index.js.map +3 -3
- 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 +83 -1
- package/dist/react/ai/index.js.map +3 -3
- package/dist/svelte/ai/index.js +83 -1
- package/dist/svelte/ai/index.js.map +3 -3
- package/dist/types/ai.d.ts +28 -1
- package/dist/vue/ai/index.js +83 -1
- package/dist/vue/ai/index.js.map +3 -3
- package/package.json +7 -7
package/dist/ai/index.js
CHANGED
|
@@ -4668,6 +4668,10 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4668
4668
|
const vectorHits = channels.includes("vector") ? 1 : 0;
|
|
4669
4669
|
const lexicalHits = channels.includes("lexical") ? 1 : 0;
|
|
4670
4670
|
const hybridHits = isHybrid ? 1 : 0;
|
|
4671
|
+
const queryOrigins = Array.isArray(source.metadata?.retrievalQueryOrigins) ? source.metadata.retrievalQueryOrigins.filter((value) => value === "primary" || value === "transformed" || value === "variant") : source.metadata?.retrievalQueryOrigin === "primary" || source.metadata?.retrievalQueryOrigin === "transformed" || source.metadata?.retrievalQueryOrigin === "variant" ? [source.metadata.retrievalQueryOrigin] : [];
|
|
4672
|
+
const primaryHits = queryOrigins.includes("primary") ? 1 : 0;
|
|
4673
|
+
const transformedHits = queryOrigins.includes("transformed") ? 1 : 0;
|
|
4674
|
+
const variantHits = queryOrigins.includes("variant") ? 1 : 0;
|
|
4671
4675
|
if (!existing) {
|
|
4672
4676
|
sections.set(key, {
|
|
4673
4677
|
bestScore: source.score,
|
|
@@ -4678,10 +4682,13 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4678
4682
|
lexicalHits,
|
|
4679
4683
|
parentLabel,
|
|
4680
4684
|
path,
|
|
4685
|
+
primaryHits,
|
|
4681
4686
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
4682
4687
|
topChunkId: source.chunkId,
|
|
4683
4688
|
topSource: source.source,
|
|
4684
4689
|
totalScore: source.score,
|
|
4690
|
+
transformedHits,
|
|
4691
|
+
variantHits,
|
|
4685
4692
|
vectorHits
|
|
4686
4693
|
});
|
|
4687
4694
|
continue;
|
|
@@ -4694,6 +4701,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4694
4701
|
existing.vectorHits += vectorHits;
|
|
4695
4702
|
existing.lexicalHits += lexicalHits;
|
|
4696
4703
|
existing.hybridHits += hybridHits;
|
|
4704
|
+
existing.primaryHits += primaryHits;
|
|
4705
|
+
existing.transformedHits += transformedHits;
|
|
4706
|
+
existing.variantHits += variantHits;
|
|
4697
4707
|
if (source.score > existing.bestScore) {
|
|
4698
4708
|
existing.bestScore = source.score;
|
|
4699
4709
|
existing.topChunkId = source.chunkId;
|
|
@@ -4704,6 +4714,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4704
4714
|
const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
|
|
4705
4715
|
const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
|
|
4706
4716
|
const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
|
|
4717
|
+
const stageSectionScores = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionScores) && step.sectionScores.length > 0).map((step) => [step.stage, step.sectionScores ?? []]));
|
|
4707
4718
|
return diagnostics.map((section) => {
|
|
4708
4719
|
const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
|
|
4709
4720
|
const siblings = siblingPool.filter((entry) => entry.key !== section.key);
|
|
@@ -4725,16 +4736,30 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4725
4736
|
stage: step.stage
|
|
4726
4737
|
})).filter((entry) => entry.count > 0) ?? [];
|
|
4727
4738
|
const stageWeights = stageCounts.map((entry) => {
|
|
4739
|
+
const previousStageEntry = stageCounts[stageCounts.findIndex((candidate) => candidate.stage === entry.stage) - 1];
|
|
4728
4740
|
const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
|
|
4741
|
+
const stageScoreEntries = stageSectionScores.get(entry.stage)?.filter((candidate) => candidate.totalScore > 0) ?? [];
|
|
4729
4742
|
const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
4743
|
+
const stageScoreTotal = stageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
4730
4744
|
const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4731
4745
|
const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4746
|
+
const siblingStageScoreEntries = stageScoreEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4747
|
+
const parentStageScoreEntries = stageScoreEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
|
|
4732
4748
|
const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
|
|
4733
4749
|
const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
|
|
4750
|
+
const activeStageScore = stageScoreEntries.find((candidate) => candidate.key === section.key)?.totalScore;
|
|
4751
|
+
const strongestStageScoreSibling = siblingStageScoreEntries.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
|
|
4752
|
+
const parentStageScoreTotal = parentStageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
|
|
4734
4753
|
const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
|
|
4754
|
+
const retentionRate = typeof previousStageEntry?.count === "number" && previousStageEntry.count > 0 ? entry.count / previousStageEntry.count : undefined;
|
|
4755
|
+
const countDelta = typeof previousStageEntry?.count === "number" ? entry.count - previousStageEntry.count : undefined;
|
|
4735
4756
|
const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
|
|
4757
|
+
const stageScoreShare = typeof activeStageScore === "number" && stageScoreTotal > 0 ? activeStageScore / stageScoreTotal : undefined;
|
|
4758
|
+
const parentStageScoreShare = typeof activeStageScore === "number" && parentStageScoreTotal > 0 ? activeStageScore / parentStageScoreTotal : undefined;
|
|
4736
4759
|
const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
|
|
4737
4760
|
const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
|
|
4761
|
+
const stageScoreShareGap = typeof activeStageScore === "number" && stageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / stageScoreTotal - strongestStageScoreSibling.totalScore / stageScoreTotal : undefined;
|
|
4762
|
+
const parentStageScoreShareGap = typeof activeStageScore === "number" && parentStageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / parentStageScoreTotal - strongestStageScoreSibling.totalScore / parentStageScoreTotal : undefined;
|
|
4738
4763
|
const reasons2 = [];
|
|
4739
4764
|
if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
|
|
4740
4765
|
reasons2.push("rerank_preserved_lead");
|
|
@@ -4748,20 +4773,65 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4748
4773
|
if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
|
|
4749
4774
|
reasons2.push("stage_runner_up_pressure");
|
|
4750
4775
|
}
|
|
4776
|
+
if (typeof countDelta === "number") {
|
|
4777
|
+
if (countDelta > 0) {
|
|
4778
|
+
reasons2.push("stage_expanded");
|
|
4779
|
+
} else if (countDelta < 0) {
|
|
4780
|
+
reasons2.push("stage_narrowed");
|
|
4781
|
+
} else {
|
|
4782
|
+
reasons2.push("stage_held");
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4751
4785
|
return {
|
|
4752
4786
|
count: entry.count,
|
|
4787
|
+
countDelta,
|
|
4788
|
+
parentStageScoreShare,
|
|
4753
4789
|
parentStageShare,
|
|
4754
4790
|
parentStageShareGap,
|
|
4791
|
+
previousCount: previousStageEntry?.count,
|
|
4792
|
+
previousStage: previousStageEntry?.stage,
|
|
4755
4793
|
reasons: reasons2,
|
|
4794
|
+
retentionRate,
|
|
4756
4795
|
stage: entry.stage,
|
|
4796
|
+
stageScoreShare,
|
|
4797
|
+
stageScoreShareGap,
|
|
4757
4798
|
stageShare,
|
|
4758
4799
|
stageShareGap,
|
|
4800
|
+
totalScore: activeStageScore,
|
|
4759
4801
|
strongestSiblingCount: strongestStageSibling?.count,
|
|
4760
4802
|
strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
|
|
4761
4803
|
};
|
|
4762
4804
|
});
|
|
4763
4805
|
const firstSeenStage = stageCounts[0]?.stage;
|
|
4764
4806
|
const lastSeenStage = stageCounts.at(-1)?.stage;
|
|
4807
|
+
const peakStageEntry = stageCounts.reduce((highest, entry) => !highest || entry.count > highest.count ? entry : highest, undefined);
|
|
4808
|
+
const finalStageEntry = stageCounts.at(-1);
|
|
4809
|
+
const peakCount = peakStageEntry?.count ?? section.count;
|
|
4810
|
+
const finalCount = finalStageEntry?.count;
|
|
4811
|
+
const finalRetentionRate = typeof finalCount === "number" && peakCount > 0 ? finalCount / peakCount : undefined;
|
|
4812
|
+
const dropFromPeak = typeof finalCount === "number" ? peakCount - finalCount : undefined;
|
|
4813
|
+
const queryAttributionReasons = [];
|
|
4814
|
+
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";
|
|
4815
|
+
if (queryAttributionMode === "primary") {
|
|
4816
|
+
queryAttributionReasons.push("base_query_only");
|
|
4817
|
+
}
|
|
4818
|
+
if (queryAttributionMode === "transformed") {
|
|
4819
|
+
queryAttributionReasons.push("transformed_query_only");
|
|
4820
|
+
queryAttributionReasons.push("transform_introduced");
|
|
4821
|
+
}
|
|
4822
|
+
if (queryAttributionMode === "variant") {
|
|
4823
|
+
queryAttributionReasons.push("variant_only");
|
|
4824
|
+
queryAttributionReasons.push("variant_supported");
|
|
4825
|
+
}
|
|
4826
|
+
if (queryAttributionMode === "mixed") {
|
|
4827
|
+
queryAttributionReasons.push("mixed_query_sources");
|
|
4828
|
+
if (section.variantHits > 0) {
|
|
4829
|
+
queryAttributionReasons.push("variant_supported");
|
|
4830
|
+
}
|
|
4831
|
+
if (section.transformedHits > 0 && section.primaryHits === 0) {
|
|
4832
|
+
queryAttributionReasons.push("transform_introduced");
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4765
4835
|
if (section.bestScore >= strongestBestHit) {
|
|
4766
4836
|
reasons.push("best_hit");
|
|
4767
4837
|
}
|
|
@@ -4795,7 +4865,19 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4795
4865
|
parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
|
|
4796
4866
|
path: section.path,
|
|
4797
4867
|
firstSeenStage,
|
|
4868
|
+
finalCount,
|
|
4869
|
+
finalRetentionRate,
|
|
4798
4870
|
lastSeenStage,
|
|
4871
|
+
dropFromPeak,
|
|
4872
|
+
peakCount,
|
|
4873
|
+
peakStage: peakStageEntry?.stage,
|
|
4874
|
+
queryAttribution: {
|
|
4875
|
+
mode: queryAttributionMode,
|
|
4876
|
+
primaryHits: section.primaryHits,
|
|
4877
|
+
reasons: queryAttributionReasons,
|
|
4878
|
+
transformedHits: section.transformedHits,
|
|
4879
|
+
variantHits: section.variantHits
|
|
4880
|
+
},
|
|
4799
4881
|
retrievalMode: trace?.mode,
|
|
4800
4882
|
reasons,
|
|
4801
4883
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
@@ -10456,9 +10538,17 @@ var mergeQueryResults = (results) => {
|
|
|
10456
10538
|
const merged = new Map;
|
|
10457
10539
|
for (const result of results) {
|
|
10458
10540
|
const existing = merged.get(result.chunkId);
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10541
|
+
const existingOrigins = Array.isArray(existing?.metadata?.retrievalQueryOrigins) ? existing.metadata.retrievalQueryOrigins.filter((value) => typeof value === "string") : typeof existing?.metadata?.retrievalQueryOrigin === "string" ? [existing.metadata.retrievalQueryOrigin] : [];
|
|
10542
|
+
const resultOrigins = Array.isArray(result.metadata?.retrievalQueryOrigins) ? result.metadata.retrievalQueryOrigins.filter((value) => typeof value === "string") : typeof result.metadata?.retrievalQueryOrigin === "string" ? [result.metadata.retrievalQueryOrigin] : [];
|
|
10543
|
+
const mergedOrigins = Array.from(new Set([...existingOrigins, ...resultOrigins]));
|
|
10544
|
+
const preferred = !existing || result.score > existing.score ? result : existing;
|
|
10545
|
+
merged.set(result.chunkId, {
|
|
10546
|
+
...preferred,
|
|
10547
|
+
metadata: {
|
|
10548
|
+
...preferred.metadata ?? {},
|
|
10549
|
+
retrievalQueryOrigins: mergedOrigins
|
|
10550
|
+
}
|
|
10551
|
+
});
|
|
10462
10552
|
}
|
|
10463
10553
|
return [...merged.values()].sort((left, right) => {
|
|
10464
10554
|
if (right.score !== left.score) {
|
|
@@ -10567,12 +10657,13 @@ var applyRAGMMRDiversity = (results, queryVector, lambda) => {
|
|
|
10567
10657
|
return [...selected, ...tail];
|
|
10568
10658
|
};
|
|
10569
10659
|
var weightQueryResults = (results, queryIndex) => {
|
|
10570
|
-
|
|
10571
|
-
return results;
|
|
10572
|
-
}
|
|
10573
|
-
const weight = Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
|
|
10660
|
+
const weight = queryIndex === 0 ? 1 : Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
|
|
10574
10661
|
return results.map((result) => ({
|
|
10575
10662
|
...result,
|
|
10663
|
+
metadata: {
|
|
10664
|
+
...result.metadata ?? {},
|
|
10665
|
+
retrievalQueryIndex: queryIndex
|
|
10666
|
+
},
|
|
10576
10667
|
score: result.score * weight
|
|
10577
10668
|
}));
|
|
10578
10669
|
};
|
|
@@ -10622,6 +10713,43 @@ var buildTraceSectionCounts = (results) => {
|
|
|
10622
10713
|
return left.key.localeCompare(right.key);
|
|
10623
10714
|
});
|
|
10624
10715
|
};
|
|
10716
|
+
var buildTraceSectionScores = (results) => {
|
|
10717
|
+
const sections = new Map;
|
|
10718
|
+
for (const result of results) {
|
|
10719
|
+
const path = Array.isArray(result.metadata?.sectionPath) ? result.metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : [];
|
|
10720
|
+
if (path.length === 0) {
|
|
10721
|
+
continue;
|
|
10722
|
+
}
|
|
10723
|
+
const key = path.join(" > ");
|
|
10724
|
+
const existing = sections.get(key);
|
|
10725
|
+
if (existing) {
|
|
10726
|
+
existing.totalScore += result.score;
|
|
10727
|
+
continue;
|
|
10728
|
+
}
|
|
10729
|
+
sections.set(key, {
|
|
10730
|
+
key,
|
|
10731
|
+
label: path.at(-1) ?? key,
|
|
10732
|
+
totalScore: result.score
|
|
10733
|
+
});
|
|
10734
|
+
}
|
|
10735
|
+
return [...sections.values()].sort((left, right) => {
|
|
10736
|
+
if (right.totalScore !== left.totalScore) {
|
|
10737
|
+
return right.totalScore - left.totalScore;
|
|
10738
|
+
}
|
|
10739
|
+
return left.key.localeCompare(right.key);
|
|
10740
|
+
});
|
|
10741
|
+
};
|
|
10742
|
+
var annotateRetrievalQueryOrigin = (input) => {
|
|
10743
|
+
const origin = input.queryIndex === 0 ? input.query === input.inputQuery ? "primary" : "transformed" : "variant";
|
|
10744
|
+
return input.results.map((result) => ({
|
|
10745
|
+
...result,
|
|
10746
|
+
metadata: {
|
|
10747
|
+
...result.metadata ?? {},
|
|
10748
|
+
retrievalQuery: input.query,
|
|
10749
|
+
retrievalQueryOrigin: origin
|
|
10750
|
+
}
|
|
10751
|
+
}));
|
|
10752
|
+
};
|
|
10625
10753
|
var shouldRunVectorRetrieval = (mode) => mode === "vector" || mode === "hybrid";
|
|
10626
10754
|
var shouldRunLexicalRetrieval = (mode, store) => mode === "lexical" || mode === "hybrid" && Boolean(store.queryLexical);
|
|
10627
10755
|
var createRAGCollection = (options) => {
|
|
@@ -10722,8 +10850,20 @@ var createRAGCollection = (options) => {
|
|
|
10722
10850
|
}) ?? Promise.resolve([]) : Promise.resolve([])
|
|
10723
10851
|
]);
|
|
10724
10852
|
return {
|
|
10725
|
-
lexicalResults:
|
|
10726
|
-
|
|
10853
|
+
lexicalResults: annotateRetrievalQueryOrigin({
|
|
10854
|
+
inputQuery: input.query,
|
|
10855
|
+
query,
|
|
10856
|
+
queryIndex,
|
|
10857
|
+
results: weightQueryResults(lexicalResults2, queryIndex),
|
|
10858
|
+
transformedQuery: transformed.query
|
|
10859
|
+
}),
|
|
10860
|
+
vectorResults: annotateRetrievalQueryOrigin({
|
|
10861
|
+
inputQuery: input.query,
|
|
10862
|
+
query,
|
|
10863
|
+
queryIndex,
|
|
10864
|
+
results: weightQueryResults(vectorResults2, queryIndex),
|
|
10865
|
+
transformedQuery: transformed.query
|
|
10866
|
+
})
|
|
10727
10867
|
};
|
|
10728
10868
|
}));
|
|
10729
10869
|
const vectorResults = mergeQueryResults(resultGroups.flatMap((group) => group.vectorResults));
|
|
@@ -10736,6 +10876,7 @@ var createRAGCollection = (options) => {
|
|
|
10736
10876
|
topK: candidateTopK
|
|
10737
10877
|
},
|
|
10738
10878
|
sectionCounts: buildTraceSectionCounts(vectorResults),
|
|
10879
|
+
sectionScores: buildTraceSectionScores(vectorResults),
|
|
10739
10880
|
stage: "vector_search"
|
|
10740
10881
|
});
|
|
10741
10882
|
}
|
|
@@ -10749,6 +10890,7 @@ var createRAGCollection = (options) => {
|
|
|
10749
10890
|
topK: lexicalTopK
|
|
10750
10891
|
},
|
|
10751
10892
|
sectionCounts: buildTraceSectionCounts(lexicalResults),
|
|
10893
|
+
sectionScores: buildTraceSectionScores(lexicalResults),
|
|
10752
10894
|
stage: "lexical_search"
|
|
10753
10895
|
});
|
|
10754
10896
|
}
|
|
@@ -10767,6 +10909,7 @@ var createRAGCollection = (options) => {
|
|
|
10767
10909
|
mode: retrieval.mode
|
|
10768
10910
|
},
|
|
10769
10911
|
sectionCounts: buildTraceSectionCounts(results),
|
|
10912
|
+
sectionScores: buildTraceSectionScores(results),
|
|
10770
10913
|
stage: "fusion"
|
|
10771
10914
|
});
|
|
10772
10915
|
const rerankInput = {
|
|
@@ -10790,6 +10933,7 @@ var createRAGCollection = (options) => {
|
|
|
10790
10933
|
applied: hasReranker
|
|
10791
10934
|
},
|
|
10792
10935
|
sectionCounts: buildTraceSectionCounts(reranked),
|
|
10936
|
+
sectionScores: buildTraceSectionScores(reranked),
|
|
10793
10937
|
stage: "rerank"
|
|
10794
10938
|
});
|
|
10795
10939
|
const diversityAdjusted = retrieval.diversityStrategy === "mmr" ? applyRAGMMRDiversity(reranked, queryVector, retrieval.mmrLambda) : reranked;
|
|
@@ -10802,6 +10946,7 @@ var createRAGCollection = (options) => {
|
|
|
10802
10946
|
mmrLambda: retrieval.mmrLambda
|
|
10803
10947
|
},
|
|
10804
10948
|
sectionCounts: buildTraceSectionCounts(diversityAdjusted),
|
|
10949
|
+
sectionScores: buildTraceSectionScores(diversityAdjusted),
|
|
10805
10950
|
stage: "diversity"
|
|
10806
10951
|
});
|
|
10807
10952
|
}
|
|
@@ -10815,6 +10960,7 @@ var createRAGCollection = (options) => {
|
|
|
10815
10960
|
strategy: retrieval.sourceBalanceStrategy
|
|
10816
10961
|
},
|
|
10817
10962
|
sectionCounts: buildTraceSectionCounts(diversified),
|
|
10963
|
+
sectionScores: buildTraceSectionScores(diversified),
|
|
10818
10964
|
stage: "source_balance"
|
|
10819
10965
|
});
|
|
10820
10966
|
}
|
|
@@ -10831,6 +10977,7 @@ var createRAGCollection = (options) => {
|
|
|
10831
10977
|
appliedScoreThreshold: false
|
|
10832
10978
|
},
|
|
10833
10979
|
sectionCounts: buildTraceSectionCounts(limited),
|
|
10980
|
+
sectionScores: buildTraceSectionScores(limited),
|
|
10834
10981
|
stage: "finalize"
|
|
10835
10982
|
});
|
|
10836
10983
|
return {
|
|
@@ -10869,6 +11016,7 @@ var createRAGCollection = (options) => {
|
|
|
10869
11016
|
scoreThreshold
|
|
10870
11017
|
},
|
|
10871
11018
|
sectionCounts: buildTraceSectionCounts(filtered),
|
|
11019
|
+
sectionScores: buildTraceSectionScores(filtered),
|
|
10872
11020
|
stage: "score_filter"
|
|
10873
11021
|
});
|
|
10874
11022
|
steps.push({
|
|
@@ -10878,6 +11026,7 @@ var createRAGCollection = (options) => {
|
|
|
10878
11026
|
appliedScoreThreshold: true
|
|
10879
11027
|
},
|
|
10880
11028
|
sectionCounts: buildTraceSectionCounts(filtered),
|
|
11029
|
+
sectionScores: buildTraceSectionScores(filtered),
|
|
10881
11030
|
stage: "finalize"
|
|
10882
11031
|
});
|
|
10883
11032
|
return {
|
|
@@ -10996,7 +11145,7 @@ var renderSectionDiagnostics = (diagnostics) => {
|
|
|
10996
11145
|
if (diagnostics.length === 0) {
|
|
10997
11146
|
return "";
|
|
10998
11147
|
}
|
|
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>`;
|
|
11148
|
+
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>` : ""}` + `<li><strong>Query attribution</strong> ${escapeHtml2(`${diagnostic.queryAttribution.mode} \xB7 primary ${diagnostic.queryAttribution.primaryHits} \xB7 transformed ${diagnostic.queryAttribution.transformedHits} \xB7 variant ${diagnostic.queryAttribution.variantHits}`)}</li>` + `${diagnostic.queryAttribution.reasons.length > 0 ? `<li><strong>Query attribution reasons</strong> ${escapeHtml2(diagnostic.queryAttribution.reasons.join(", "))}</li>` : ""}` + `${diagnostic.peakStage ? `<li><strong>Peak stage</strong> ${escapeHtml2(diagnostic.peakStage)} (${diagnostic.peakCount})</li>` : ""}` + `${typeof diagnostic.finalRetentionRate === "number" ? `<li><strong>Final retention</strong> ${(diagnostic.finalRetentionRate * 100).toFixed(0)}%</li>` : ""}` + `${typeof diagnostic.dropFromPeak === "number" ? `<li><strong>Drop from peak</strong> ${diagnostic.dropFromPeak}</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.retentionRate === "number" ? ` \xB7 ${(entry.retentionRate * 100).toFixed(0)}% retained from ${escapeHtml2(entry.previousStage ?? "previous")}` : ""}` + `${typeof entry.countDelta === "number" ? ` \xB7 delta ${entry.countDelta >= 0 ? "+" : ""}${entry.countDelta}` : ""}` + `${typeof entry.stageScoreShare === "number" ? ` \xB7 ${(entry.stageScoreShare * 100).toFixed(0)}% of stage score` : ""}` + `${typeof entry.parentStageScoreShare === "number" ? ` \xB7 ${(entry.parentStageScoreShare * 100).toFixed(0)}% of parent stage score` : ""}` + `${typeof entry.stageScoreShareGap === "number" ? ` \xB7 score gap ${(entry.stageScoreShareGap * 100).toFixed(0)}%` : ""}` + `${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>`;
|
|
11000
11149
|
};
|
|
11001
11150
|
var renderEmptyState = (kind) => {
|
|
11002
11151
|
switch (kind) {
|
|
@@ -22291,5 +22440,5 @@ export {
|
|
|
22291
22440
|
aiChat
|
|
22292
22441
|
};
|
|
22293
22442
|
|
|
22294
|
-
//# debugId=
|
|
22443
|
+
//# debugId=593D26DEF70C96A364756E2164756E21
|
|
22295
22444
|
//# sourceMappingURL=index.js.map
|