@absolutejs/absolute 0.19.0-beta.644 → 0.19.0-beta.645
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 +694 -11
- package/dist/ai/client/index.js.map +6 -6
- package/dist/ai/client/ui.js +573 -11
- package/dist/ai/client/ui.js.map +5 -5
- package/dist/ai/index.js +2150 -136
- package/dist/ai/index.js.map +10 -10
- package/dist/ai/rag/quality.js +577 -11
- package/dist/ai/rag/quality.js.map +5 -5
- package/dist/ai/rag/ui.js +573 -11
- package/dist/ai/rag/ui.js.map +5 -5
- package/dist/ai-client/angular/ai/index.js +388 -8
- package/dist/ai-client/react/ai/index.js +388 -8
- package/dist/ai-client/vue/ai/index.js +388 -8
- package/dist/angular/ai/index.js +694 -11
- package/dist/angular/ai/index.js.map +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +2 -2
- package/dist/react/ai/index.js +694 -11
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ragClient.d.ts +58 -0
- package/dist/src/ai/index.d.ts +2 -1
- package/dist/src/ai/rag/chat.d.ts +90 -4
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/quality.d.ts +20 -1
- package/dist/src/vue/ai/useRAG.d.ts +80 -0
- package/dist/src/vue/ai/useRAGEvaluate.d.ts +70 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +10 -0
- package/dist/svelte/ai/index.js +694 -11
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +56 -13
- package/dist/types/index.d.ts +1 -0
- package/dist/types/session.d.ts +16 -0
- package/dist/vue/ai/index.js +694 -11
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +2 -1
|
@@ -969,12 +969,21 @@ var createRAGClient = (options) => {
|
|
|
969
969
|
if (typeof input?.limit === "number") {
|
|
970
970
|
searchParams.set("limit", String(input.limit));
|
|
971
971
|
}
|
|
972
|
+
if (typeof input?.runLimit === "number") {
|
|
973
|
+
searchParams.set("runLimit", String(input.runLimit));
|
|
974
|
+
}
|
|
972
975
|
if (input?.label) {
|
|
973
976
|
searchParams.set("label", input.label);
|
|
974
977
|
}
|
|
975
978
|
if (input?.description) {
|
|
976
979
|
searchParams.set("description", input.description);
|
|
977
980
|
}
|
|
981
|
+
if (input?.groupKey) {
|
|
982
|
+
searchParams.set("benchmarkGroupKey", input.groupKey);
|
|
983
|
+
}
|
|
984
|
+
if (input?.corpusGroupKey) {
|
|
985
|
+
searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
|
|
986
|
+
}
|
|
978
987
|
const suffix = searchParams.size ? `?${searchParams}` : "";
|
|
979
988
|
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner${suffix}`);
|
|
980
989
|
if (!response.ok) {
|
|
@@ -986,6 +995,35 @@ var createRAGClient = (options) => {
|
|
|
986
995
|
}
|
|
987
996
|
return payload;
|
|
988
997
|
},
|
|
998
|
+
async runAdaptiveNativePlannerBenchmark(input) {
|
|
999
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/run`, {
|
|
1000
|
+
body: JSON.stringify({
|
|
1001
|
+
baselineRetrievalId: input?.baselineRetrievalId,
|
|
1002
|
+
candidateRetrievalId: input?.candidateRetrievalId,
|
|
1003
|
+
corpusGroupKey: input?.corpusGroupKey,
|
|
1004
|
+
description: input?.description,
|
|
1005
|
+
groupKey: input?.groupKey,
|
|
1006
|
+
label: input?.label,
|
|
1007
|
+
limit: input?.limit,
|
|
1008
|
+
metadata: input?.metadata,
|
|
1009
|
+
persistRun: input?.persistRun,
|
|
1010
|
+
retrievals: input?.retrievals,
|
|
1011
|
+
runLimit: input?.runLimit,
|
|
1012
|
+
tags: input?.tags,
|
|
1013
|
+
topK: input?.topK
|
|
1014
|
+
}),
|
|
1015
|
+
headers: jsonHeaders,
|
|
1016
|
+
method: "POST"
|
|
1017
|
+
});
|
|
1018
|
+
if (!response.ok) {
|
|
1019
|
+
throw new Error(await toErrorMessage(response));
|
|
1020
|
+
}
|
|
1021
|
+
const payload = await parseJson(response);
|
|
1022
|
+
if (!payload.ok) {
|
|
1023
|
+
throw new Error(payload.error ?? "Adaptive native planner benchmark run failed");
|
|
1024
|
+
}
|
|
1025
|
+
return payload;
|
|
1026
|
+
},
|
|
989
1027
|
async saveAdaptiveNativePlannerBenchmarkSnapshot(input) {
|
|
990
1028
|
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/snapshots`, {
|
|
991
1029
|
body: JSON.stringify({
|
|
@@ -1009,6 +1047,89 @@ var createRAGClient = (options) => {
|
|
|
1009
1047
|
}
|
|
1010
1048
|
return payload;
|
|
1011
1049
|
},
|
|
1050
|
+
async nativeBackendComparisonBenchmark(input) {
|
|
1051
|
+
const searchParams = new URLSearchParams;
|
|
1052
|
+
if (typeof input?.limit === "number") {
|
|
1053
|
+
searchParams.set("limit", String(input.limit));
|
|
1054
|
+
}
|
|
1055
|
+
if (typeof input?.runLimit === "number") {
|
|
1056
|
+
searchParams.set("runLimit", String(input.runLimit));
|
|
1057
|
+
}
|
|
1058
|
+
if (input?.label) {
|
|
1059
|
+
searchParams.set("label", input.label);
|
|
1060
|
+
}
|
|
1061
|
+
if (input?.description) {
|
|
1062
|
+
searchParams.set("description", input.description);
|
|
1063
|
+
}
|
|
1064
|
+
if (input?.groupKey) {
|
|
1065
|
+
searchParams.set("benchmarkGroupKey", input.groupKey);
|
|
1066
|
+
}
|
|
1067
|
+
if (input?.corpusGroupKey) {
|
|
1068
|
+
searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
|
|
1069
|
+
}
|
|
1070
|
+
const suffix = searchParams.size ? `?${searchParams}` : "";
|
|
1071
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison${suffix}`);
|
|
1072
|
+
if (!response.ok) {
|
|
1073
|
+
throw new Error(await toErrorMessage(response));
|
|
1074
|
+
}
|
|
1075
|
+
const payload = await parseJson(response);
|
|
1076
|
+
if (!payload.ok) {
|
|
1077
|
+
throw new Error(payload.error ?? "Native backend comparison benchmark history failed");
|
|
1078
|
+
}
|
|
1079
|
+
return payload;
|
|
1080
|
+
},
|
|
1081
|
+
async runNativeBackendComparisonBenchmark(input) {
|
|
1082
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/run`, {
|
|
1083
|
+
body: JSON.stringify({
|
|
1084
|
+
baselineRetrievalId: input?.baselineRetrievalId,
|
|
1085
|
+
candidateRetrievalId: input?.candidateRetrievalId,
|
|
1086
|
+
corpusGroupKey: input?.corpusGroupKey,
|
|
1087
|
+
description: input?.description,
|
|
1088
|
+
groupKey: input?.groupKey,
|
|
1089
|
+
label: input?.label,
|
|
1090
|
+
limit: input?.limit,
|
|
1091
|
+
metadata: input?.metadata,
|
|
1092
|
+
persistRun: input?.persistRun,
|
|
1093
|
+
retrievals: input?.retrievals,
|
|
1094
|
+
runLimit: input?.runLimit,
|
|
1095
|
+
tags: input?.tags,
|
|
1096
|
+
topK: input?.topK
|
|
1097
|
+
}),
|
|
1098
|
+
headers: jsonHeaders,
|
|
1099
|
+
method: "POST"
|
|
1100
|
+
});
|
|
1101
|
+
if (!response.ok) {
|
|
1102
|
+
throw new Error(await toErrorMessage(response));
|
|
1103
|
+
}
|
|
1104
|
+
const payload = await parseJson(response);
|
|
1105
|
+
if (!payload.ok) {
|
|
1106
|
+
throw new Error(payload.error ?? "Native backend comparison benchmark run failed");
|
|
1107
|
+
}
|
|
1108
|
+
return payload;
|
|
1109
|
+
},
|
|
1110
|
+
async saveNativeBackendComparisonBenchmarkSnapshot(input) {
|
|
1111
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/snapshots`, {
|
|
1112
|
+
body: JSON.stringify({
|
|
1113
|
+
createdAt: input?.createdAt,
|
|
1114
|
+
description: input?.description,
|
|
1115
|
+
label: input?.label,
|
|
1116
|
+
limit: input?.limit,
|
|
1117
|
+
metadata: input?.metadata,
|
|
1118
|
+
snapshotMetadata: input?.snapshotMetadata,
|
|
1119
|
+
version: input?.version
|
|
1120
|
+
}),
|
|
1121
|
+
headers: jsonHeaders,
|
|
1122
|
+
method: "POST"
|
|
1123
|
+
});
|
|
1124
|
+
if (!response.ok) {
|
|
1125
|
+
throw new Error(await toErrorMessage(response));
|
|
1126
|
+
}
|
|
1127
|
+
const payload = await parseJson(response);
|
|
1128
|
+
if (!payload.ok) {
|
|
1129
|
+
throw new Error(payload.error ?? "Native backend comparison benchmark snapshot failed");
|
|
1130
|
+
}
|
|
1131
|
+
return payload;
|
|
1132
|
+
},
|
|
1012
1133
|
async retrievalLaneHandoffs(input) {
|
|
1013
1134
|
const searchParams = new URLSearchParams;
|
|
1014
1135
|
if (input?.groupKey) {
|
|
@@ -1812,6 +1933,7 @@ var buildContextLabel = (metadata) => {
|
|
|
1812
1933
|
return;
|
|
1813
1934
|
}
|
|
1814
1935
|
const emailKind = getContextString(metadata.emailKind);
|
|
1936
|
+
const officeBlockKind = getContextString(metadata.officeBlockKind);
|
|
1815
1937
|
if (emailKind === "attachment") {
|
|
1816
1938
|
return "Attachment evidence";
|
|
1817
1939
|
}
|
|
@@ -1849,6 +1971,16 @@ var buildContextLabel = (metadata) => {
|
|
|
1849
1971
|
}
|
|
1850
1972
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
1851
1973
|
const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
1974
|
+
const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
|
|
1975
|
+
if (officeBlockKind === "table" && officeSectionLabel) {
|
|
1976
|
+
return `Office table block ${officeSectionLabel}`;
|
|
1977
|
+
}
|
|
1978
|
+
if (officeBlockKind === "list" && officeSectionLabel) {
|
|
1979
|
+
return `Office list block ${officeSectionLabel}`;
|
|
1980
|
+
}
|
|
1981
|
+
if (officeBlockKind === "paragraph" && officeSectionLabel) {
|
|
1982
|
+
return `Office paragraph block ${officeSectionLabel}`;
|
|
1983
|
+
}
|
|
1852
1984
|
if (sectionTitle) {
|
|
1853
1985
|
return `Section ${sectionTitle}`;
|
|
1854
1986
|
}
|
|
@@ -1870,6 +2002,46 @@ var formatMediaDurationLabel = (value) => {
|
|
|
1870
2002
|
}
|
|
1871
2003
|
return formatMediaTimestamp(value);
|
|
1872
2004
|
};
|
|
2005
|
+
var formatOfficeListLevelsLabel = (value) => {
|
|
2006
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
const levels = value.map((entry) => getContextNumber(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
|
|
2010
|
+
if (levels.length === 0) {
|
|
2011
|
+
return;
|
|
2012
|
+
}
|
|
2013
|
+
const minLevel = levels[0];
|
|
2014
|
+
const maxLevel = levels[levels.length - 1];
|
|
2015
|
+
return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
|
|
2016
|
+
};
|
|
2017
|
+
var getOfficeTableCitationScope = (metadata) => {
|
|
2018
|
+
if (!metadata) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
const officeBlockKind = getContextString(metadata.officeBlockKind);
|
|
2022
|
+
if (officeBlockKind !== "table" && officeBlockKind !== "list") {
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
2026
|
+
const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
2027
|
+
const officeContextText = officeBlockKind === "table" ? getContextString(metadata.officeTableContextText) : getContextString(metadata.officeListContextText);
|
|
2028
|
+
if (!sectionTitle) {
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
return {
|
|
2032
|
+
blockKind: officeBlockKind,
|
|
2033
|
+
pathDepth: sectionPath.length,
|
|
2034
|
+
sectionTitle,
|
|
2035
|
+
hasContext: typeof officeContextText === "string"
|
|
2036
|
+
};
|
|
2037
|
+
};
|
|
2038
|
+
var getOfficeTableCitationPreference = (metadata) => {
|
|
2039
|
+
const scope = getOfficeTableCitationScope(metadata);
|
|
2040
|
+
if (!scope) {
|
|
2041
|
+
return 0;
|
|
2042
|
+
}
|
|
2043
|
+
return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
|
|
2044
|
+
};
|
|
1873
2045
|
var buildLocatorLabel = (metadata, source, title) => {
|
|
1874
2046
|
if (!metadata) {
|
|
1875
2047
|
return;
|
|
@@ -1895,6 +2067,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
1895
2067
|
return `Archive entry ${archiveEntry}`;
|
|
1896
2068
|
}
|
|
1897
2069
|
const emailKind = getContextString(metadata.emailKind);
|
|
2070
|
+
const officeBlockKind = getContextString(metadata.officeBlockKind);
|
|
2071
|
+
const officeBlockNumber = getContextNumber(metadata.officeBlockNumber);
|
|
2072
|
+
const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
|
|
2073
|
+
const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
|
|
1898
2074
|
if (emailKind === "attachment") {
|
|
1899
2075
|
const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
|
|
1900
2076
|
return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
|
|
@@ -1907,6 +2083,18 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
1907
2083
|
if (mediaStart) {
|
|
1908
2084
|
return `Timestamp ${mediaStart}`;
|
|
1909
2085
|
}
|
|
2086
|
+
if (officeBlockNumber && officeBlockKind === "table") {
|
|
2087
|
+
if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
|
|
2088
|
+
return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
|
|
2089
|
+
}
|
|
2090
|
+
return `Office table block ${officeBlockNumber}`;
|
|
2091
|
+
}
|
|
2092
|
+
if (officeBlockNumber && officeBlockKind === "list") {
|
|
2093
|
+
return `Office list block ${officeBlockNumber}`;
|
|
2094
|
+
}
|
|
2095
|
+
if (officeBlockNumber && officeBlockKind === "paragraph") {
|
|
2096
|
+
return `Office paragraph block ${officeBlockNumber}`;
|
|
2097
|
+
}
|
|
1910
2098
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
1911
2099
|
if (sectionPath.length > 0) {
|
|
1912
2100
|
return `Section ${sectionPath.join(" > ")}`;
|
|
@@ -1940,10 +2128,31 @@ var buildProvenanceLabel = (metadata) => {
|
|
|
1940
2128
|
const mediaDurationLabel = formatMediaDurationLabel(metadata.mediaDurationMs);
|
|
1941
2129
|
const transcriptSource = getContextString(metadata.transcriptSource);
|
|
1942
2130
|
const pdfTextMode = getContextString(metadata.pdfTextMode);
|
|
2131
|
+
const officeBlockKind = getContextString(metadata.officeBlockKind);
|
|
2132
|
+
const officeListContextText = getContextString(metadata.officeListContextText);
|
|
2133
|
+
const officeListGroupItemCount = getContextNumber(metadata.officeListGroupItemCount);
|
|
2134
|
+
const officeListLevelsLabel = formatOfficeListLevelsLabel(metadata.officeListLevels);
|
|
2135
|
+
const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
2136
|
+
const officeTableColumnCount = getContextNumber(metadata.officeTableColumnCount);
|
|
2137
|
+
const officeTableBodyRowCount = getContextNumber(metadata.officeTableBodyRowCount);
|
|
2138
|
+
const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
|
|
2139
|
+
const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
|
|
2140
|
+
const officeTableContextText = getContextString(metadata.officeTableContextText);
|
|
2141
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
1943
2142
|
const ocrEngine = getContextString(metadata.ocrEngine);
|
|
1944
2143
|
const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
|
|
1945
2144
|
const labels = [
|
|
1946
2145
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
2146
|
+
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
2147
|
+
typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
|
|
2148
|
+
officeListLevelsLabel ?? "",
|
|
2149
|
+
sectionPath.length > 0 && officeBlockKind ? `Source-aware office ${officeBlockKind} block ${sectionPath.join(" > ")}` : "",
|
|
2150
|
+
officeListContextText ? `Office list context ${officeListContextText}` : "",
|
|
2151
|
+
officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
|
|
2152
|
+
typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
|
|
2153
|
+
typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
|
|
2154
|
+
typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
|
|
2155
|
+
officeTableContextText ? `Office table context ${officeTableContextText}` : "",
|
|
1947
2156
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
1948
2157
|
typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
|
|
1949
2158
|
mediaKind ? `Media ${mediaKind}` : "",
|
|
@@ -2107,6 +2316,15 @@ var buildRAGCitations = (sources) => {
|
|
|
2107
2316
|
});
|
|
2108
2317
|
}
|
|
2109
2318
|
return [...unique.values()].sort((left, right) => {
|
|
2319
|
+
const leftOfficeScope = getOfficeTableCitationScope(left.metadata);
|
|
2320
|
+
const rightOfficeScope = getOfficeTableCitationScope(right.metadata);
|
|
2321
|
+
if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
|
|
2322
|
+
const leftOfficePreference = getOfficeTableCitationPreference(left.metadata);
|
|
2323
|
+
const rightOfficePreference = getOfficeTableCitationPreference(right.metadata);
|
|
2324
|
+
if (rightOfficePreference !== leftOfficePreference) {
|
|
2325
|
+
return rightOfficePreference - leftOfficePreference;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2110
2328
|
if (right.score !== left.score) {
|
|
2111
2329
|
return right.score - left.score;
|
|
2112
2330
|
}
|
|
@@ -2679,6 +2897,7 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2679
2897
|
const sectionKind = getContextString2(metadata.sectionKind);
|
|
2680
2898
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
2681
2899
|
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
2900
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
2682
2901
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
2683
2902
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2684
2903
|
const sheetName = getContextString2(metadata.sheetName);
|
|
@@ -2689,6 +2908,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2689
2908
|
return `Source-aware section ${sectionPath.join(" > ")}`;
|
|
2690
2909
|
}
|
|
2691
2910
|
if (sectionKind === "pdf_block") {
|
|
2911
|
+
if (pdfSemanticRole === "figure_caption" && sectionTitle) {
|
|
2912
|
+
return `Source-aware PDF figure caption ${sectionTitle}`;
|
|
2913
|
+
}
|
|
2914
|
+
if (pdfSemanticRole === "figure_body" && sectionTitle) {
|
|
2915
|
+
return `Source-aware PDF figure body ${sectionTitle}`;
|
|
2916
|
+
}
|
|
2692
2917
|
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
2693
2918
|
return `Source-aware PDF table block ${sectionTitle}`;
|
|
2694
2919
|
}
|
|
@@ -2698,11 +2923,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2698
2923
|
return "Source-aware PDF block";
|
|
2699
2924
|
}
|
|
2700
2925
|
if (sectionKind === "office_block") {
|
|
2701
|
-
|
|
2702
|
-
|
|
2926
|
+
const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
|
|
2927
|
+
if (officeBlockKind && officeSectionLabel) {
|
|
2928
|
+
return `Source-aware office ${officeBlockKind} block ${officeSectionLabel}`;
|
|
2703
2929
|
}
|
|
2704
|
-
if (
|
|
2705
|
-
return `Source-aware office block ${
|
|
2930
|
+
if (officeSectionLabel) {
|
|
2931
|
+
return `Source-aware office block ${officeSectionLabel}`;
|
|
2706
2932
|
}
|
|
2707
2933
|
return "Source-aware office block";
|
|
2708
2934
|
}
|
|
@@ -2784,6 +3010,18 @@ var formatSpreadsheetTableLabel = (tableIndex, tableCount) => {
|
|
|
2784
3010
|
}
|
|
2785
3011
|
return `Table ${tableIndex}`;
|
|
2786
3012
|
};
|
|
3013
|
+
var formatOfficeListLevelsLabel2 = (value) => {
|
|
3014
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3015
|
+
return;
|
|
3016
|
+
}
|
|
3017
|
+
const levels = value.map((entry) => getContextNumber2(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
|
|
3018
|
+
if (levels.length === 0) {
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
const minLevel = levels[0];
|
|
3022
|
+
const maxLevel = levels[levels.length - 1];
|
|
3023
|
+
return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
|
|
3024
|
+
};
|
|
2787
3025
|
var formatMediaDurationLabel2 = (value) => {
|
|
2788
3026
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
2789
3027
|
return;
|
|
@@ -2795,9 +3033,18 @@ var buildContextLabel2 = (metadata) => {
|
|
|
2795
3033
|
return;
|
|
2796
3034
|
}
|
|
2797
3035
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3036
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
3037
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3038
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
2798
3039
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2799
3040
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
2800
3041
|
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
3042
|
+
if (pdfSemanticRole === "figure_caption" && sectionTitle) {
|
|
3043
|
+
return `PDF figure caption ${sectionTitle}`;
|
|
3044
|
+
}
|
|
3045
|
+
if (pdfSemanticRole === "figure_body" && sectionTitle) {
|
|
3046
|
+
return `PDF figure body ${sectionTitle}`;
|
|
3047
|
+
}
|
|
2801
3048
|
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
2802
3049
|
return `PDF table block ${sectionTitle}`;
|
|
2803
3050
|
}
|
|
@@ -2805,13 +3052,13 @@ var buildContextLabel2 = (metadata) => {
|
|
|
2805
3052
|
return `PDF text block ${sectionTitle}`;
|
|
2806
3053
|
}
|
|
2807
3054
|
if (officeBlockKind === "table" && sectionTitle) {
|
|
2808
|
-
return `Office table block ${sectionTitle}`;
|
|
3055
|
+
return `Office table block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2809
3056
|
}
|
|
2810
3057
|
if (officeBlockKind === "list" && sectionTitle) {
|
|
2811
|
-
return `Office list block ${sectionTitle}`;
|
|
3058
|
+
return `Office list block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2812
3059
|
}
|
|
2813
3060
|
if (officeBlockKind === "paragraph" && sectionTitle) {
|
|
2814
|
-
return `Office paragraph block ${sectionTitle}`;
|
|
3061
|
+
return `Office paragraph block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2815
3062
|
}
|
|
2816
3063
|
const emailKind = getContextString2(metadata.emailKind);
|
|
2817
3064
|
if (emailKind === "attachment") {
|
|
@@ -2909,9 +3156,14 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2909
3156
|
return;
|
|
2910
3157
|
}
|
|
2911
3158
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3159
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
2912
3160
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2913
3161
|
const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
|
|
3162
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3163
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
2914
3164
|
const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
|
|
3165
|
+
const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
|
|
3166
|
+
const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
|
|
2915
3167
|
const spreadsheetRowStart = getContextNumber2(metadata.spreadsheetRowStart);
|
|
2916
3168
|
const spreadsheetRowEnd = getContextNumber2(metadata.spreadsheetRowEnd);
|
|
2917
3169
|
const slideTitle = getContextString2(metadata.slideTitle);
|
|
@@ -2922,7 +3174,16 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2922
3174
|
if (page && region) {
|
|
2923
3175
|
return `Page ${page} · Region ${region}`;
|
|
2924
3176
|
}
|
|
3177
|
+
if (page && pdfBlockNumber && pdfSemanticRole === "figure_caption") {
|
|
3178
|
+
return `Page ${page} · Figure Caption ${pdfBlockNumber}`;
|
|
3179
|
+
}
|
|
3180
|
+
if (page && pdfBlockNumber && pdfSemanticRole === "figure_body") {
|
|
3181
|
+
return `Page ${page} · Figure Body ${pdfBlockNumber}`;
|
|
3182
|
+
}
|
|
2925
3183
|
if (page && pdfBlockNumber && pdfTextKind === "table_like") {
|
|
3184
|
+
if (typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number") {
|
|
3185
|
+
return pdfTableBodyRowStart === pdfTableBodyRowEnd ? `Page ${page} · Table Block ${pdfBlockNumber} · Row ${pdfTableBodyRowStart}` : `Page ${page} · Table Block ${pdfBlockNumber} · Rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}`;
|
|
3186
|
+
}
|
|
2926
3187
|
return `Page ${page} · Table Block ${pdfBlockNumber}`;
|
|
2927
3188
|
}
|
|
2928
3189
|
if (page && pdfBlockNumber) {
|
|
@@ -2985,6 +3246,9 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2985
3246
|
return `Timestamp ${mediaStart}`;
|
|
2986
3247
|
}
|
|
2987
3248
|
if (officeBlockNumber && officeBlockKind === "table") {
|
|
3249
|
+
if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
|
|
3250
|
+
return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
|
|
3251
|
+
}
|
|
2988
3252
|
return `Office table block ${officeBlockNumber}`;
|
|
2989
3253
|
}
|
|
2990
3254
|
if (officeBlockNumber && officeBlockKind === "list") {
|
|
@@ -3021,11 +3285,27 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
3021
3285
|
const mediaSegmentWindowDurationLabel = formatMediaDurationLabel2(metadata.mediaSegmentGroupDurationMs);
|
|
3022
3286
|
const mediaSegmentGapLabel = formatMediaDurationLabel2(metadata.mediaSegmentGapFromPreviousMs);
|
|
3023
3287
|
const spreadsheetHeaders = getSpreadsheetHeaders(metadata);
|
|
3288
|
+
const pdfTableHeaders = Array.isArray(metadata.pdfTableHeaders) ? metadata.pdfTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
3289
|
+
const pdfTableColumnCount = getContextNumber2(metadata.pdfTableColumnCount);
|
|
3290
|
+
const pdfTableBodyRowCount = getContextNumber2(metadata.pdfTableBodyRowCount);
|
|
3024
3291
|
const spreadsheetColumnRange = formatSpreadsheetColumnRange(getContextString2(metadata.spreadsheetColumnStart), getContextString2(metadata.spreadsheetColumnEnd));
|
|
3025
3292
|
const slideNotesText = getContextString2(metadata.slideNotesText);
|
|
3026
3293
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
3294
|
+
const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
|
|
3295
|
+
const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
|
|
3296
|
+
const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
|
|
3027
3297
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3298
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
3028
3299
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
3300
|
+
const officeListContextText = getContextString2(metadata.officeListContextText);
|
|
3301
|
+
const officeListGroupItemCount = getContextNumber2(metadata.officeListGroupItemCount);
|
|
3302
|
+
const officeListLevelsLabel = formatOfficeListLevelsLabel2(metadata.officeListLevels);
|
|
3303
|
+
const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
3304
|
+
const officeTableColumnCount = getContextNumber2(metadata.officeTableColumnCount);
|
|
3305
|
+
const officeTableBodyRowCount = getContextNumber2(metadata.officeTableBodyRowCount);
|
|
3306
|
+
const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
|
|
3307
|
+
const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
|
|
3308
|
+
const officeTableContextText = getContextString2(metadata.officeTableContextText);
|
|
3029
3309
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
3030
3310
|
const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
|
|
3031
3311
|
const chunkingProfile = getContextString2(metadata.chunkingProfile);
|
|
@@ -3041,10 +3321,19 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
3041
3321
|
const ocrMinConfidence = getContextNumber2(metadata.ocrPageMinConfidence) ?? getContextNumber2(metadata.ocrMinConfidence);
|
|
3042
3322
|
const ocrMaxConfidence = getContextNumber2(metadata.ocrPageMaxConfidence) ?? getContextNumber2(metadata.ocrMaxConfidence);
|
|
3043
3323
|
const ocrRegionCount = getContextNumber2(metadata.ocrRegionCount);
|
|
3324
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3325
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
3044
3326
|
const labels = [
|
|
3045
3327
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
3046
|
-
|
|
3328
|
+
pdfEvidenceMode ? `PDF evidence ${pdfEvidenceMode}` : "",
|
|
3329
|
+
pdfEvidenceOrigin ? `PDF origin ${pdfEvidenceOrigin}` : "",
|
|
3330
|
+
pdfEvidenceSupplement ? `PDF supplement ${pdfEvidenceSupplement}` : "",
|
|
3331
|
+
pdfSemanticRole === "figure_caption" ? "PDF figure caption" : "",
|
|
3332
|
+
pdfSemanticRole === "figure_body" ? "PDF figure body" : "",
|
|
3333
|
+
pdfSemanticRole === "figure_caption" ? "" : pdfSemanticRole === "figure_body" ? "" : pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
|
|
3047
3334
|
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
3335
|
+
typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
|
|
3336
|
+
officeListLevelsLabel ?? "",
|
|
3048
3337
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
3049
3338
|
extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
|
|
3050
3339
|
chunkingProfile ? `Chunking ${chunkingProfile}` : "",
|
|
@@ -3054,6 +3343,16 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
3054
3343
|
typeof ocrAverageConfidence === "number" && ocrAverageConfidence !== ocrConfidence ? `Average ${ocrAverageConfidence.toFixed(2)}` : "",
|
|
3055
3344
|
typeof ocrMinConfidence === "number" && typeof ocrMaxConfidence === "number" && ocrMinConfidence !== ocrMaxConfidence ? `Range ${ocrMinConfidence.toFixed(2)}-${ocrMaxConfidence.toFixed(2)}` : "",
|
|
3056
3345
|
typeof ocrRegionCount === "number" ? `${ocrRegionCount} regions` : "",
|
|
3346
|
+
pdfTableHeaders.length > 0 ? `PDF table ${pdfTableHeaders.join(", ")}` : "",
|
|
3347
|
+
typeof pdfTableColumnCount === "number" ? `PDF table ${pdfTableColumnCount} cols` : "",
|
|
3348
|
+
typeof pdfTableBodyRowCount === "number" ? `PDF table ${pdfTableBodyRowCount} body rows` : "",
|
|
3349
|
+
typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number" ? pdfTableBodyRowStart === pdfTableBodyRowEnd ? `PDF table row ${pdfTableBodyRowStart}` : `PDF table rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}` : "",
|
|
3350
|
+
officeListContextText ? `Office list context ${officeListContextText}` : "",
|
|
3351
|
+
officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
|
|
3352
|
+
typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
|
|
3353
|
+
typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
|
|
3354
|
+
typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
|
|
3355
|
+
officeTableContextText ? `Office table context ${officeTableContextText}` : "",
|
|
3057
3356
|
spreadsheetHeaders.length > 0 ? `Spreadsheet ${spreadsheetHeaders.join(", ")}` : "",
|
|
3058
3357
|
spreadsheetColumnRange ? `Spreadsheet ${spreadsheetColumnRange}` : "",
|
|
3059
3358
|
spreadsheetTableLabel ? `Spreadsheet ${spreadsheetTableLabel}` : "",
|
|
@@ -3485,12 +3784,92 @@ var getStructuredSectionScoreWeight = (metadata) => {
|
|
|
3485
3784
|
return 1;
|
|
3486
3785
|
};
|
|
3487
3786
|
var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
3787
|
+
var getPDFLeadEvidencePreference = (metadata) => {
|
|
3788
|
+
if (!metadata) {
|
|
3789
|
+
return 0;
|
|
3790
|
+
}
|
|
3791
|
+
const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
|
|
3792
|
+
const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
|
|
3793
|
+
const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
|
|
3794
|
+
if (pdfEvidenceMode === "hybrid" && pdfEvidenceOrigin === "native" && pdfEvidenceSupplement === "ocr") {
|
|
3795
|
+
return 3;
|
|
3796
|
+
}
|
|
3797
|
+
if (pdfEvidenceMode === "native" && pdfEvidenceOrigin === "native") {
|
|
3798
|
+
return 2;
|
|
3799
|
+
}
|
|
3800
|
+
if (pdfEvidenceMode === "ocr" && pdfEvidenceOrigin === "ocr") {
|
|
3801
|
+
return 1;
|
|
3802
|
+
}
|
|
3803
|
+
return 0;
|
|
3804
|
+
};
|
|
3805
|
+
var getPDFLeadScope = (metadata) => {
|
|
3806
|
+
if (!metadata) {
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3809
|
+
const pageNumber = getContextNumber2(metadata.pageNumber) ?? getContextNumber2(metadata.page) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
3810
|
+
const sectionTitle = getContextString2(metadata.sectionTitle);
|
|
3811
|
+
const sourceNativeKind = getContextString2(metadata.sourceNativeKind);
|
|
3812
|
+
if (typeof pageNumber !== "number" && !sectionTitle && !sourceNativeKind) {
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
return {
|
|
3816
|
+
pageNumber,
|
|
3817
|
+
sectionTitle,
|
|
3818
|
+
sourceNativeKind
|
|
3819
|
+
};
|
|
3820
|
+
};
|
|
3821
|
+
var getOfficeLeadScope = (metadata) => {
|
|
3822
|
+
if (!metadata) {
|
|
3823
|
+
return;
|
|
3824
|
+
}
|
|
3825
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
3826
|
+
if (officeBlockKind !== "table" && officeBlockKind !== "list") {
|
|
3827
|
+
return;
|
|
3828
|
+
}
|
|
3829
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
3830
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
3831
|
+
const officeContextText = officeBlockKind === "table" ? getContextString2(metadata.officeTableContextText) : getContextString2(metadata.officeListContextText);
|
|
3832
|
+
if (!sectionTitle) {
|
|
3833
|
+
return;
|
|
3834
|
+
}
|
|
3835
|
+
return {
|
|
3836
|
+
blockKind: officeBlockKind,
|
|
3837
|
+
pathDepth: sectionPath.length,
|
|
3838
|
+
sectionTitle,
|
|
3839
|
+
hasContext: typeof officeContextText === "string"
|
|
3840
|
+
};
|
|
3841
|
+
};
|
|
3842
|
+
var getOfficeLeadEvidencePreference = (metadata) => {
|
|
3843
|
+
const scope = getOfficeLeadScope(metadata);
|
|
3844
|
+
if (!scope) {
|
|
3845
|
+
return 0;
|
|
3846
|
+
}
|
|
3847
|
+
return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
|
|
3848
|
+
};
|
|
3488
3849
|
var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
|
|
3850
|
+
const leftOfficeScope = getOfficeLeadScope(left.metadata);
|
|
3851
|
+
const rightOfficeScope = getOfficeLeadScope(right.metadata);
|
|
3852
|
+
if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
|
|
3853
|
+
const leftOfficePreference = getOfficeLeadEvidencePreference(left.metadata);
|
|
3854
|
+
const rightOfficePreference = getOfficeLeadEvidencePreference(right.metadata);
|
|
3855
|
+
if (rightOfficePreference !== leftOfficePreference) {
|
|
3856
|
+
return rightOfficePreference - leftOfficePreference;
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3489
3859
|
const leftWeightedScore = getStructuredSourceLeadScore(left);
|
|
3490
3860
|
const rightWeightedScore = getStructuredSourceLeadScore(right);
|
|
3491
3861
|
if (rightWeightedScore !== leftWeightedScore) {
|
|
3492
3862
|
return rightWeightedScore - leftWeightedScore;
|
|
3493
3863
|
}
|
|
3864
|
+
const leftScope = getPDFLeadScope(left.metadata);
|
|
3865
|
+
const rightScope = getPDFLeadScope(right.metadata);
|
|
3866
|
+
if (left.source === right.source && leftScope && rightScope && (leftScope.sectionTitle && rightScope.sectionTitle && leftScope.sectionTitle === rightScope.sectionTitle || typeof leftScope.pageNumber === "number" && typeof rightScope.pageNumber === "number" && leftScope.pageNumber === rightScope.pageNumber)) {
|
|
3867
|
+
const leftEvidencePreference = getPDFLeadEvidencePreference(left.metadata);
|
|
3868
|
+
const rightEvidencePreference = getPDFLeadEvidencePreference(right.metadata);
|
|
3869
|
+
if (rightEvidencePreference !== leftEvidencePreference) {
|
|
3870
|
+
return rightEvidencePreference - leftEvidencePreference;
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3494
3873
|
if (right.score !== left.score) {
|
|
3495
3874
|
return right.score - left.score;
|
|
3496
3875
|
}
|
|
@@ -3744,6 +4123,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
3744
4123
|
queryTransformProvider: trace?.queryTransformProvider,
|
|
3745
4124
|
queryTransformReason: trace?.queryTransformReason,
|
|
3746
4125
|
reasons,
|
|
4126
|
+
evidenceReconcileApplied: trace?.steps.some((step) => step.stage === "evidence_reconcile"),
|
|
3747
4127
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
3748
4128
|
scoreShare,
|
|
3749
4129
|
scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
|