@absolutejs/absolute 0.19.0-beta.643 → 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 +976 -15
- package/dist/ai/client/index.js.map +6 -6
- package/dist/ai/client/ui.js +807 -15
- package/dist/ai/client/ui.js.map +5 -5
- package/dist/ai/index.js +2737 -141
- package/dist/ai/index.js.map +13 -13
- package/dist/ai/rag/quality.js +813 -15
- package/dist/ai/rag/quality.js.map +5 -5
- package/dist/ai/rag/ui.js +807 -15
- package/dist/ai/rag/ui.js.map +5 -5
- package/dist/ai-client/angular/ai/index.js +436 -8
- package/dist/ai-client/react/ai/index.js +436 -8
- package/dist/ai-client/vue/ai/index.js +436 -8
- package/dist/angular/ai/index.js +976 -15
- 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 +976 -15
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ragClient.d.ts +74 -1
- package/dist/src/ai/index.d.ts +2 -1
- package/dist/src/ai/rag/adapters/queryPlanning.d.ts +8 -0
- package/dist/src/ai/rag/chat.d.ts +135 -7
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/presentation.d.ts +5 -1
- package/dist/src/ai/rag/quality.d.ts +34 -1
- package/dist/src/vue/ai/useRAG.d.ts +84 -0
- package/dist/src/vue/ai/useRAGEvaluate.d.ts +74 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +10 -0
- package/dist/svelte/ai/index.js +976 -15
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +115 -13
- package/dist/types/index.d.ts +1 -0
- package/dist/types/session.d.ts +16 -0
- package/dist/vue/ai/index.js +976 -15
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +8 -7
|
@@ -948,6 +948,9 @@ var createRAGClient = (options) => {
|
|
|
948
948
|
if (typeof input.runLimit === "number") {
|
|
949
949
|
searchParams.set("runLimit", String(input.runLimit));
|
|
950
950
|
}
|
|
951
|
+
if (typeof input.benchmarkLimit === "number") {
|
|
952
|
+
searchParams.set("benchmarkLimit", String(input.benchmarkLimit));
|
|
953
|
+
}
|
|
951
954
|
if (input.targetRolloutLabel) {
|
|
952
955
|
searchParams.set("targetRolloutLabel", input.targetRolloutLabel);
|
|
953
956
|
}
|
|
@@ -961,6 +964,172 @@ var createRAGClient = (options) => {
|
|
|
961
964
|
}
|
|
962
965
|
return payload;
|
|
963
966
|
},
|
|
967
|
+
async adaptiveNativePlannerBenchmark(input) {
|
|
968
|
+
const searchParams = new URLSearchParams;
|
|
969
|
+
if (typeof input?.limit === "number") {
|
|
970
|
+
searchParams.set("limit", String(input.limit));
|
|
971
|
+
}
|
|
972
|
+
if (typeof input?.runLimit === "number") {
|
|
973
|
+
searchParams.set("runLimit", String(input.runLimit));
|
|
974
|
+
}
|
|
975
|
+
if (input?.label) {
|
|
976
|
+
searchParams.set("label", input.label);
|
|
977
|
+
}
|
|
978
|
+
if (input?.description) {
|
|
979
|
+
searchParams.set("description", input.description);
|
|
980
|
+
}
|
|
981
|
+
if (input?.groupKey) {
|
|
982
|
+
searchParams.set("benchmarkGroupKey", input.groupKey);
|
|
983
|
+
}
|
|
984
|
+
if (input?.corpusGroupKey) {
|
|
985
|
+
searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
|
|
986
|
+
}
|
|
987
|
+
const suffix = searchParams.size ? `?${searchParams}` : "";
|
|
988
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner${suffix}`);
|
|
989
|
+
if (!response.ok) {
|
|
990
|
+
throw new Error(await toErrorMessage(response));
|
|
991
|
+
}
|
|
992
|
+
const payload = await parseJson(response);
|
|
993
|
+
if (!payload.ok) {
|
|
994
|
+
throw new Error(payload.error ?? "Adaptive native planner benchmark history failed");
|
|
995
|
+
}
|
|
996
|
+
return payload;
|
|
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
|
+
},
|
|
1027
|
+
async saveAdaptiveNativePlannerBenchmarkSnapshot(input) {
|
|
1028
|
+
const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/snapshots`, {
|
|
1029
|
+
body: JSON.stringify({
|
|
1030
|
+
createdAt: input?.createdAt,
|
|
1031
|
+
description: input?.description,
|
|
1032
|
+
label: input?.label,
|
|
1033
|
+
limit: input?.limit,
|
|
1034
|
+
metadata: input?.metadata,
|
|
1035
|
+
snapshotMetadata: input?.snapshotMetadata,
|
|
1036
|
+
version: input?.version
|
|
1037
|
+
}),
|
|
1038
|
+
headers: jsonHeaders,
|
|
1039
|
+
method: "POST"
|
|
1040
|
+
});
|
|
1041
|
+
if (!response.ok) {
|
|
1042
|
+
throw new Error(await toErrorMessage(response));
|
|
1043
|
+
}
|
|
1044
|
+
const payload = await parseJson(response);
|
|
1045
|
+
if (!payload.ok) {
|
|
1046
|
+
throw new Error(payload.error ?? "Adaptive native planner benchmark snapshot failed");
|
|
1047
|
+
}
|
|
1048
|
+
return payload;
|
|
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
|
+
},
|
|
964
1133
|
async retrievalLaneHandoffs(input) {
|
|
965
1134
|
const searchParams = new URLSearchParams;
|
|
966
1135
|
if (input?.groupKey) {
|
|
@@ -1764,6 +1933,7 @@ var buildContextLabel = (metadata) => {
|
|
|
1764
1933
|
return;
|
|
1765
1934
|
}
|
|
1766
1935
|
const emailKind = getContextString(metadata.emailKind);
|
|
1936
|
+
const officeBlockKind = getContextString(metadata.officeBlockKind);
|
|
1767
1937
|
if (emailKind === "attachment") {
|
|
1768
1938
|
return "Attachment evidence";
|
|
1769
1939
|
}
|
|
@@ -1801,6 +1971,16 @@ var buildContextLabel = (metadata) => {
|
|
|
1801
1971
|
}
|
|
1802
1972
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
1803
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
|
+
}
|
|
1804
1984
|
if (sectionTitle) {
|
|
1805
1985
|
return `Section ${sectionTitle}`;
|
|
1806
1986
|
}
|
|
@@ -1822,6 +2002,46 @@ var formatMediaDurationLabel = (value) => {
|
|
|
1822
2002
|
}
|
|
1823
2003
|
return formatMediaTimestamp(value);
|
|
1824
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
|
+
};
|
|
1825
2045
|
var buildLocatorLabel = (metadata, source, title) => {
|
|
1826
2046
|
if (!metadata) {
|
|
1827
2047
|
return;
|
|
@@ -1847,6 +2067,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
1847
2067
|
return `Archive entry ${archiveEntry}`;
|
|
1848
2068
|
}
|
|
1849
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);
|
|
1850
2074
|
if (emailKind === "attachment") {
|
|
1851
2075
|
const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
|
|
1852
2076
|
return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
|
|
@@ -1859,6 +2083,18 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
1859
2083
|
if (mediaStart) {
|
|
1860
2084
|
return `Timestamp ${mediaStart}`;
|
|
1861
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
|
+
}
|
|
1862
2098
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
1863
2099
|
if (sectionPath.length > 0) {
|
|
1864
2100
|
return `Section ${sectionPath.join(" > ")}`;
|
|
@@ -1892,10 +2128,31 @@ var buildProvenanceLabel = (metadata) => {
|
|
|
1892
2128
|
const mediaDurationLabel = formatMediaDurationLabel(metadata.mediaDurationMs);
|
|
1893
2129
|
const transcriptSource = getContextString(metadata.transcriptSource);
|
|
1894
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") : [];
|
|
1895
2142
|
const ocrEngine = getContextString(metadata.ocrEngine);
|
|
1896
2143
|
const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
|
|
1897
2144
|
const labels = [
|
|
1898
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}` : "",
|
|
1899
2156
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
1900
2157
|
typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
|
|
1901
2158
|
mediaKind ? `Media ${mediaKind}` : "",
|
|
@@ -2059,6 +2316,15 @@ var buildRAGCitations = (sources) => {
|
|
|
2059
2316
|
});
|
|
2060
2317
|
}
|
|
2061
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
|
+
}
|
|
2062
2328
|
if (right.score !== left.score) {
|
|
2063
2329
|
return right.score - left.score;
|
|
2064
2330
|
}
|
|
@@ -2631,6 +2897,7 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2631
2897
|
const sectionKind = getContextString2(metadata.sectionKind);
|
|
2632
2898
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
2633
2899
|
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
2900
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
2634
2901
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
2635
2902
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2636
2903
|
const sheetName = getContextString2(metadata.sheetName);
|
|
@@ -2641,6 +2908,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2641
2908
|
return `Source-aware section ${sectionPath.join(" > ")}`;
|
|
2642
2909
|
}
|
|
2643
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
|
+
}
|
|
2644
2917
|
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
2645
2918
|
return `Source-aware PDF table block ${sectionTitle}`;
|
|
2646
2919
|
}
|
|
@@ -2650,11 +2923,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
|
|
|
2650
2923
|
return "Source-aware PDF block";
|
|
2651
2924
|
}
|
|
2652
2925
|
if (sectionKind === "office_block") {
|
|
2653
|
-
|
|
2654
|
-
|
|
2926
|
+
const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
|
|
2927
|
+
if (officeBlockKind && officeSectionLabel) {
|
|
2928
|
+
return `Source-aware office ${officeBlockKind} block ${officeSectionLabel}`;
|
|
2655
2929
|
}
|
|
2656
|
-
if (
|
|
2657
|
-
return `Source-aware office block ${
|
|
2930
|
+
if (officeSectionLabel) {
|
|
2931
|
+
return `Source-aware office block ${officeSectionLabel}`;
|
|
2658
2932
|
}
|
|
2659
2933
|
return "Source-aware office block";
|
|
2660
2934
|
}
|
|
@@ -2736,6 +3010,18 @@ var formatSpreadsheetTableLabel = (tableIndex, tableCount) => {
|
|
|
2736
3010
|
}
|
|
2737
3011
|
return `Table ${tableIndex}`;
|
|
2738
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
|
+
};
|
|
2739
3025
|
var formatMediaDurationLabel2 = (value) => {
|
|
2740
3026
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
2741
3027
|
return;
|
|
@@ -2747,9 +3033,18 @@ var buildContextLabel2 = (metadata) => {
|
|
|
2747
3033
|
return;
|
|
2748
3034
|
}
|
|
2749
3035
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3036
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
3037
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3038
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
2750
3039
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2751
3040
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
2752
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
|
+
}
|
|
2753
3048
|
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
2754
3049
|
return `PDF table block ${sectionTitle}`;
|
|
2755
3050
|
}
|
|
@@ -2757,13 +3052,13 @@ var buildContextLabel2 = (metadata) => {
|
|
|
2757
3052
|
return `PDF text block ${sectionTitle}`;
|
|
2758
3053
|
}
|
|
2759
3054
|
if (officeBlockKind === "table" && sectionTitle) {
|
|
2760
|
-
return `Office table block ${sectionTitle}`;
|
|
3055
|
+
return `Office table block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2761
3056
|
}
|
|
2762
3057
|
if (officeBlockKind === "list" && sectionTitle) {
|
|
2763
|
-
return `Office list block ${sectionTitle}`;
|
|
3058
|
+
return `Office list block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2764
3059
|
}
|
|
2765
3060
|
if (officeBlockKind === "paragraph" && sectionTitle) {
|
|
2766
|
-
return `Office paragraph block ${sectionTitle}`;
|
|
3061
|
+
return `Office paragraph block ${sectionPath.join(" > ") || sectionTitle}`;
|
|
2767
3062
|
}
|
|
2768
3063
|
const emailKind = getContextString2(metadata.emailKind);
|
|
2769
3064
|
if (emailKind === "attachment") {
|
|
@@ -2861,9 +3156,14 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2861
3156
|
return;
|
|
2862
3157
|
}
|
|
2863
3158
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3159
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
2864
3160
|
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
2865
3161
|
const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
|
|
3162
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3163
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
2866
3164
|
const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
|
|
3165
|
+
const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
|
|
3166
|
+
const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
|
|
2867
3167
|
const spreadsheetRowStart = getContextNumber2(metadata.spreadsheetRowStart);
|
|
2868
3168
|
const spreadsheetRowEnd = getContextNumber2(metadata.spreadsheetRowEnd);
|
|
2869
3169
|
const slideTitle = getContextString2(metadata.slideTitle);
|
|
@@ -2874,7 +3174,16 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2874
3174
|
if (page && region) {
|
|
2875
3175
|
return `Page ${page} · Region ${region}`;
|
|
2876
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
|
+
}
|
|
2877
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
|
+
}
|
|
2878
3187
|
return `Page ${page} · Table Block ${pdfBlockNumber}`;
|
|
2879
3188
|
}
|
|
2880
3189
|
if (page && pdfBlockNumber) {
|
|
@@ -2937,6 +3246,9 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
2937
3246
|
return `Timestamp ${mediaStart}`;
|
|
2938
3247
|
}
|
|
2939
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
|
+
}
|
|
2940
3252
|
return `Office table block ${officeBlockNumber}`;
|
|
2941
3253
|
}
|
|
2942
3254
|
if (officeBlockNumber && officeBlockKind === "list") {
|
|
@@ -2973,11 +3285,27 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
2973
3285
|
const mediaSegmentWindowDurationLabel = formatMediaDurationLabel2(metadata.mediaSegmentGroupDurationMs);
|
|
2974
3286
|
const mediaSegmentGapLabel = formatMediaDurationLabel2(metadata.mediaSegmentGapFromPreviousMs);
|
|
2975
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);
|
|
2976
3291
|
const spreadsheetColumnRange = formatSpreadsheetColumnRange(getContextString2(metadata.spreadsheetColumnStart), getContextString2(metadata.spreadsheetColumnEnd));
|
|
2977
3292
|
const slideNotesText = getContextString2(metadata.slideNotesText);
|
|
2978
3293
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
3294
|
+
const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
|
|
3295
|
+
const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
|
|
3296
|
+
const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
|
|
2979
3297
|
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
3298
|
+
const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
|
|
2980
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);
|
|
2981
3309
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
2982
3310
|
const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
|
|
2983
3311
|
const chunkingProfile = getContextString2(metadata.chunkingProfile);
|
|
@@ -2993,10 +3321,19 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
2993
3321
|
const ocrMinConfidence = getContextNumber2(metadata.ocrPageMinConfidence) ?? getContextNumber2(metadata.ocrMinConfidence);
|
|
2994
3322
|
const ocrMaxConfidence = getContextNumber2(metadata.ocrPageMaxConfidence) ?? getContextNumber2(metadata.ocrMaxConfidence);
|
|
2995
3323
|
const ocrRegionCount = getContextNumber2(metadata.ocrRegionCount);
|
|
3324
|
+
const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
|
|
3325
|
+
const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
|
|
2996
3326
|
const labels = [
|
|
2997
3327
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
2998
|
-
|
|
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" : "",
|
|
2999
3334
|
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
3335
|
+
typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
|
|
3336
|
+
officeListLevelsLabel ?? "",
|
|
3000
3337
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
3001
3338
|
extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
|
|
3002
3339
|
chunkingProfile ? `Chunking ${chunkingProfile}` : "",
|
|
@@ -3006,6 +3343,16 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
3006
3343
|
typeof ocrAverageConfidence === "number" && ocrAverageConfidence !== ocrConfidence ? `Average ${ocrAverageConfidence.toFixed(2)}` : "",
|
|
3007
3344
|
typeof ocrMinConfidence === "number" && typeof ocrMaxConfidence === "number" && ocrMinConfidence !== ocrMaxConfidence ? `Range ${ocrMinConfidence.toFixed(2)}-${ocrMaxConfidence.toFixed(2)}` : "",
|
|
3008
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}` : "",
|
|
3009
3356
|
spreadsheetHeaders.length > 0 ? `Spreadsheet ${spreadsheetHeaders.join(", ")}` : "",
|
|
3010
3357
|
spreadsheetColumnRange ? `Spreadsheet ${spreadsheetColumnRange}` : "",
|
|
3011
3358
|
spreadsheetTableLabel ? `Spreadsheet ${spreadsheetTableLabel}` : "",
|
|
@@ -3437,12 +3784,92 @@ var getStructuredSectionScoreWeight = (metadata) => {
|
|
|
3437
3784
|
return 1;
|
|
3438
3785
|
};
|
|
3439
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
|
+
};
|
|
3440
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
|
+
}
|
|
3441
3859
|
const leftWeightedScore = getStructuredSourceLeadScore(left);
|
|
3442
3860
|
const rightWeightedScore = getStructuredSourceLeadScore(right);
|
|
3443
3861
|
if (rightWeightedScore !== leftWeightedScore) {
|
|
3444
3862
|
return rightWeightedScore - leftWeightedScore;
|
|
3445
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
|
+
}
|
|
3446
3873
|
if (right.score !== left.score) {
|
|
3447
3874
|
return right.score - left.score;
|
|
3448
3875
|
}
|
|
@@ -3696,6 +4123,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
3696
4123
|
queryTransformProvider: trace?.queryTransformProvider,
|
|
3697
4124
|
queryTransformReason: trace?.queryTransformReason,
|
|
3698
4125
|
reasons,
|
|
4126
|
+
evidenceReconcileApplied: trace?.steps.some((step) => step.stage === "evidence_reconcile"),
|
|
3699
4127
|
rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
|
|
3700
4128
|
scoreShare,
|
|
3701
4129
|
scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
|