@absolutejs/absolute 0.19.0-beta.603 → 0.19.0-beta.605
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 +244 -10
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +248 -10
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +1003 -110
- package/dist/ai/index.js.map +8 -8
- package/dist/ai/rag/quality.js +27 -6
- package/dist/ai/rag/quality.js.map +3 -3
- package/dist/ai/rag/ui.js +248 -10
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +243 -9
- package/dist/ai-client/react/ai/index.js +258 -10
- package/dist/ai-client/vue/ai/index.js +347 -101
- package/dist/angular/ai/index.js +244 -10
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/react/ai/index.js +259 -11
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/ai/client/ui.d.ts +1 -1
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/presentation.d.ts +12 -1
- package/dist/src/ai/rag/ui.d.ts +1 -1
- package/dist/src/react/ai/useRAG.d.ts +5 -0
- package/dist/src/react/ai/useRAGChunkPreview.d.ts +4 -0
- package/dist/src/react/ai/useRAGSources.d.ts +1 -0
- package/dist/src/svelte/ai/createRAG.d.ts +5 -0
- package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +4 -0
- package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
- package/dist/src/vue/ai/useRAG.d.ts +125 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +54 -0
- package/dist/src/vue/ai/useRAGDocuments.d.ts +20 -0
- package/dist/src/vue/ai/useRAGIndexAdmin.d.ts +10 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +40 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
- package/dist/svelte/ai/index.js +305 -57
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +102 -1
- package/dist/vue/ai/index.js +311 -63
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
package/dist/ai/rag/ui.js
CHANGED
|
@@ -105,6 +105,10 @@ var buildContextLabel = (metadata) => {
|
|
|
105
105
|
return from ? `Message from ${from}` : "Message evidence";
|
|
106
106
|
}
|
|
107
107
|
const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
108
|
+
const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
109
|
+
if (page && region) {
|
|
110
|
+
return `Page ${page} region ${region}`;
|
|
111
|
+
}
|
|
108
112
|
if (page) {
|
|
109
113
|
return `Page ${page}`;
|
|
110
114
|
}
|
|
@@ -128,6 +132,11 @@ var buildContextLabel = (metadata) => {
|
|
|
128
132
|
if (speaker) {
|
|
129
133
|
return `Speaker ${speaker}`;
|
|
130
134
|
}
|
|
135
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
136
|
+
const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
137
|
+
if (sectionTitle) {
|
|
138
|
+
return `Section ${sectionTitle}`;
|
|
139
|
+
}
|
|
131
140
|
return;
|
|
132
141
|
};
|
|
133
142
|
var formatMediaTimestamp = (value) => {
|
|
@@ -145,6 +154,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
145
154
|
return;
|
|
146
155
|
}
|
|
147
156
|
const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
157
|
+
const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
158
|
+
if (page && region) {
|
|
159
|
+
return `Page ${page} \xB7 Region ${region}`;
|
|
160
|
+
}
|
|
148
161
|
if (page) {
|
|
149
162
|
return `Page ${page}`;
|
|
150
163
|
}
|
|
@@ -173,6 +186,10 @@ var buildLocatorLabel = (metadata, source, title) => {
|
|
|
173
186
|
if (mediaStart) {
|
|
174
187
|
return `Timestamp ${mediaStart}`;
|
|
175
188
|
}
|
|
189
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
|
|
190
|
+
if (sectionPath.length > 0) {
|
|
191
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
192
|
+
}
|
|
176
193
|
return;
|
|
177
194
|
};
|
|
178
195
|
var formatTimestampLabel = (value) => {
|
|
@@ -197,9 +214,11 @@ var buildProvenanceLabel = (metadata) => {
|
|
|
197
214
|
const transcriptSource = getContextString(metadata.transcriptSource);
|
|
198
215
|
const pdfTextMode = getContextString(metadata.pdfTextMode);
|
|
199
216
|
const ocrEngine = getContextString(metadata.ocrEngine);
|
|
217
|
+
const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
|
|
200
218
|
const labels = [
|
|
201
219
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
202
220
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
221
|
+
typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
|
|
203
222
|
mediaKind ? `Media ${mediaKind}` : "",
|
|
204
223
|
transcriptSource ? `Transcript ${transcriptSource}` : "",
|
|
205
224
|
threadTopic ? `Thread ${threadTopic}` : "",
|
|
@@ -220,8 +239,10 @@ var buildExcerpt = (text, maxLength = 160) => {
|
|
|
220
239
|
var buildGroundingReferenceEvidenceLabel = (reference) => [reference.label, reference.locatorLabel, reference.contextLabel].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
221
240
|
var buildGroundingReferenceEvidenceSummary = (reference) => [
|
|
222
241
|
reference.source ?? reference.title ?? reference.chunkId,
|
|
242
|
+
reference.locatorLabel,
|
|
243
|
+
reference.contextLabel,
|
|
223
244
|
reference.provenanceLabel
|
|
224
|
-
].filter((value) => Boolean(value && value.length > 0)).join(" \xB7 ");
|
|
245
|
+
].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
|
|
225
246
|
var buildGroundedAnswerCitationDetail = (reference) => ({
|
|
226
247
|
contextLabel: reference.contextLabel,
|
|
227
248
|
evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
|
|
@@ -245,12 +266,12 @@ var buildRAGCitations = (sources) => {
|
|
|
245
266
|
continue;
|
|
246
267
|
unique.set(key, {
|
|
247
268
|
chunkId: source.chunkId,
|
|
248
|
-
contextLabel: buildContextLabel(source.metadata),
|
|
269
|
+
contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
|
|
249
270
|
key,
|
|
250
271
|
label: buildSourceLabel(source),
|
|
251
|
-
locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
|
|
272
|
+
locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
|
|
252
273
|
metadata: source.metadata,
|
|
253
|
-
provenanceLabel: buildProvenanceLabel(source.metadata),
|
|
274
|
+
provenanceLabel: source.labels?.provenanceLabel ?? buildProvenanceLabel(source.metadata),
|
|
254
275
|
score: source.score,
|
|
255
276
|
source: source.source,
|
|
256
277
|
text: source.text,
|
|
@@ -320,7 +341,7 @@ var buildRAGGroundingReferences = (sources) => {
|
|
|
320
341
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
321
342
|
return citations.map((citation) => ({
|
|
322
343
|
chunkId: citation.chunkId,
|
|
323
|
-
contextLabel: buildContextLabel(citation.metadata),
|
|
344
|
+
contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
|
|
324
345
|
excerpt: buildExcerpt(citation.text),
|
|
325
346
|
label: citation.label,
|
|
326
347
|
locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
|
|
@@ -795,6 +816,10 @@ var buildContextLabel2 = (metadata) => {
|
|
|
795
816
|
return from ? `Message from ${from}` : "Message evidence";
|
|
796
817
|
}
|
|
797
818
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
819
|
+
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
820
|
+
if (page && region) {
|
|
821
|
+
return `Page ${page} region ${region}`;
|
|
822
|
+
}
|
|
798
823
|
if (page) {
|
|
799
824
|
return `Page ${page}`;
|
|
800
825
|
}
|
|
@@ -818,6 +843,11 @@ var buildContextLabel2 = (metadata) => {
|
|
|
818
843
|
if (speaker) {
|
|
819
844
|
return `Speaker ${speaker}`;
|
|
820
845
|
}
|
|
846
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
847
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
848
|
+
if (sectionTitle) {
|
|
849
|
+
return `Section ${sectionTitle}`;
|
|
850
|
+
}
|
|
821
851
|
return;
|
|
822
852
|
};
|
|
823
853
|
var buildLocatorLabel2 = (metadata, source, title) => {
|
|
@@ -825,6 +855,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
825
855
|
return;
|
|
826
856
|
}
|
|
827
857
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
858
|
+
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
859
|
+
if (page && region) {
|
|
860
|
+
return `Page ${page} \xB7 Region ${region}`;
|
|
861
|
+
}
|
|
828
862
|
if (page) {
|
|
829
863
|
return `Page ${page}`;
|
|
830
864
|
}
|
|
@@ -853,6 +887,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
853
887
|
if (mediaStart) {
|
|
854
888
|
return `Timestamp ${mediaStart}`;
|
|
855
889
|
}
|
|
890
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
891
|
+
if (sectionPath.length > 0) {
|
|
892
|
+
return `Section ${sectionPath.join(" > ")}`;
|
|
893
|
+
}
|
|
856
894
|
return;
|
|
857
895
|
};
|
|
858
896
|
var buildProvenanceLabel2 = (metadata) => {
|
|
@@ -867,9 +905,11 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
867
905
|
const transcriptSource = getContextString2(metadata.transcriptSource);
|
|
868
906
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
869
907
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
908
|
+
const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
|
|
870
909
|
const labels = [
|
|
871
910
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
872
911
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
912
|
+
typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
|
|
873
913
|
mediaKind ? `Media ${mediaKind}` : "",
|
|
874
914
|
transcriptSource ? `Transcript ${transcriptSource}` : "",
|
|
875
915
|
threadTopic ? `Thread ${threadTopic}` : "",
|
|
@@ -879,6 +919,50 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
879
919
|
].filter((value) => value.length > 0);
|
|
880
920
|
return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
|
|
881
921
|
};
|
|
922
|
+
var buildRAGSourceLabels = ({
|
|
923
|
+
metadata,
|
|
924
|
+
source,
|
|
925
|
+
title
|
|
926
|
+
}) => {
|
|
927
|
+
const contextLabel = buildContextLabel2(metadata);
|
|
928
|
+
const locatorLabel = buildLocatorLabel2(metadata, source, title);
|
|
929
|
+
const provenanceLabel = buildProvenanceLabel2(metadata);
|
|
930
|
+
if (!contextLabel && !locatorLabel && !provenanceLabel) {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
contextLabel,
|
|
935
|
+
locatorLabel,
|
|
936
|
+
provenanceLabel
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
var buildRAGChunkStructure = (metadata) => {
|
|
940
|
+
if (!metadata) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
944
|
+
const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" ? metadata.sectionKind : undefined;
|
|
945
|
+
const section = {
|
|
946
|
+
depth: getContextNumber2(metadata.sectionDepth),
|
|
947
|
+
kind: sectionKind,
|
|
948
|
+
path: sectionPath && sectionPath.length > 0 ? sectionPath : undefined,
|
|
949
|
+
title: getContextString2(metadata.sectionTitle)
|
|
950
|
+
};
|
|
951
|
+
const sequence = {
|
|
952
|
+
nextChunkId: getContextString2(metadata.nextChunkId),
|
|
953
|
+
previousChunkId: getContextString2(metadata.previousChunkId),
|
|
954
|
+
sectionChunkCount: getContextNumber2(metadata.sectionChunkCount),
|
|
955
|
+
sectionChunkId: getContextString2(metadata.sectionChunkId),
|
|
956
|
+
sectionChunkIndex: getContextNumber2(metadata.sectionChunkIndex)
|
|
957
|
+
};
|
|
958
|
+
if (!section.title && (!section.path || section.path.length === 0) && typeof section.depth !== "number" && !section.kind && !sequence.nextChunkId && !sequence.previousChunkId && typeof sequence.sectionChunkCount !== "number" && !sequence.sectionChunkId && typeof sequence.sectionChunkIndex !== "number") {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
return {
|
|
962
|
+
section: section.title || section.path && section.path.length > 0 || typeof section.depth === "number" || section.kind ? section : undefined,
|
|
963
|
+
sequence: sequence.nextChunkId || sequence.previousChunkId || typeof sequence.sectionChunkCount === "number" || sequence.sectionChunkId || typeof sequence.sectionChunkIndex === "number" ? sequence : undefined
|
|
964
|
+
};
|
|
965
|
+
};
|
|
882
966
|
var buildExcerpt2 = (text, maxLength = 160) => {
|
|
883
967
|
const normalized = text.replaceAll(/\s+/g, " ").trim();
|
|
884
968
|
if (normalized.length <= maxLength) {
|
|
@@ -886,6 +970,136 @@ var buildExcerpt2 = (text, maxLength = 160) => {
|
|
|
886
970
|
}
|
|
887
971
|
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
888
972
|
};
|
|
973
|
+
var buildRAGChunkGraph = (chunks) => {
|
|
974
|
+
const nodes = [];
|
|
975
|
+
const edges = [];
|
|
976
|
+
const edgeKeys = new Set;
|
|
977
|
+
const sections = new Map;
|
|
978
|
+
for (const chunk of chunks) {
|
|
979
|
+
const labels = chunk.labels ?? buildRAGSourceLabels({
|
|
980
|
+
metadata: chunk.metadata,
|
|
981
|
+
source: chunk.source,
|
|
982
|
+
title: chunk.title
|
|
983
|
+
});
|
|
984
|
+
const structure = chunk.structure ?? buildRAGChunkStructure(chunk.metadata);
|
|
985
|
+
nodes.push({
|
|
986
|
+
chunkId: chunk.chunkId,
|
|
987
|
+
contextLabel: labels?.contextLabel,
|
|
988
|
+
label: chunk.source ?? chunk.title ?? chunk.chunkId,
|
|
989
|
+
locatorLabel: labels?.locatorLabel,
|
|
990
|
+
provenanceLabel: labels?.provenanceLabel,
|
|
991
|
+
score: chunk.score,
|
|
992
|
+
source: chunk.source,
|
|
993
|
+
structure,
|
|
994
|
+
title: chunk.title
|
|
995
|
+
});
|
|
996
|
+
const previousChunkId = structure?.sequence?.previousChunkId;
|
|
997
|
+
if (previousChunkId) {
|
|
998
|
+
const key = `previous:${previousChunkId}:${chunk.chunkId}`;
|
|
999
|
+
if (!edgeKeys.has(key)) {
|
|
1000
|
+
edgeKeys.add(key);
|
|
1001
|
+
edges.push({
|
|
1002
|
+
fromChunkId: previousChunkId,
|
|
1003
|
+
relation: "previous",
|
|
1004
|
+
toChunkId: chunk.chunkId
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
const nextChunkId = structure?.sequence?.nextChunkId;
|
|
1009
|
+
if (nextChunkId) {
|
|
1010
|
+
const key = `next:${chunk.chunkId}:${nextChunkId}`;
|
|
1011
|
+
if (!edgeKeys.has(key)) {
|
|
1012
|
+
edgeKeys.add(key);
|
|
1013
|
+
edges.push({
|
|
1014
|
+
fromChunkId: chunk.chunkId,
|
|
1015
|
+
relation: "next",
|
|
1016
|
+
toChunkId: nextChunkId
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
const sectionId = structure?.sequence?.sectionChunkId;
|
|
1021
|
+
if (sectionId) {
|
|
1022
|
+
const existing = sections.get(sectionId);
|
|
1023
|
+
if (!existing) {
|
|
1024
|
+
sections.set(sectionId, {
|
|
1025
|
+
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1026
|
+
chunkIds: [chunk.chunkId],
|
|
1027
|
+
depth: structure.section?.depth,
|
|
1028
|
+
id: sectionId,
|
|
1029
|
+
kind: structure.section?.kind,
|
|
1030
|
+
path: structure.section?.path,
|
|
1031
|
+
title: structure.section?.title
|
|
1032
|
+
});
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
if (!existing.chunkIds.includes(chunk.chunkId)) {
|
|
1036
|
+
existing.chunkIds.push(chunk.chunkId);
|
|
1037
|
+
}
|
|
1038
|
+
existing.chunkCount = Math.max(existing.chunkCount, structure.sequence?.sectionChunkCount ?? existing.chunkCount);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
for (const section of sections.values()) {
|
|
1042
|
+
section.chunkIds.sort((left, right) => {
|
|
1043
|
+
const leftNode = nodes.find((node) => node.chunkId === left);
|
|
1044
|
+
const rightNode = nodes.find((node) => node.chunkId === right);
|
|
1045
|
+
const leftIndex = leftNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1046
|
+
const rightIndex = rightNode?.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1047
|
+
if (leftIndex !== rightIndex) {
|
|
1048
|
+
return leftIndex - rightIndex;
|
|
1049
|
+
}
|
|
1050
|
+
return left.localeCompare(right);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
nodes.sort((left, right) => {
|
|
1054
|
+
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1055
|
+
const rightSection = right.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
1056
|
+
if (leftSection !== rightSection) {
|
|
1057
|
+
return leftSection - rightSection;
|
|
1058
|
+
}
|
|
1059
|
+
const leftScore = left.score ?? Number.NEGATIVE_INFINITY;
|
|
1060
|
+
const rightScore = right.score ?? Number.NEGATIVE_INFINITY;
|
|
1061
|
+
if (leftScore !== rightScore) {
|
|
1062
|
+
return rightScore - leftScore;
|
|
1063
|
+
}
|
|
1064
|
+
return left.label.localeCompare(right.label);
|
|
1065
|
+
});
|
|
1066
|
+
return {
|
|
1067
|
+
edges,
|
|
1068
|
+
nodes,
|
|
1069
|
+
sections: [...sections.values()].sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
var buildRAGChunkPreviewGraph = (preview) => buildRAGChunkGraph(preview.chunks.map((chunk) => ({
|
|
1073
|
+
chunkId: chunk.chunkId,
|
|
1074
|
+
labels: chunk.labels,
|
|
1075
|
+
metadata: chunk.metadata,
|
|
1076
|
+
source: chunk.source ?? preview.document.source,
|
|
1077
|
+
structure: chunk.structure,
|
|
1078
|
+
title: chunk.title ?? preview.document.title
|
|
1079
|
+
})));
|
|
1080
|
+
var buildRAGChunkPreviewNavigation = (preview, activeChunkId) => buildRAGChunkGraphNavigation(buildRAGChunkPreviewGraph(preview), activeChunkId);
|
|
1081
|
+
var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
1082
|
+
if (graph.nodes.length === 0) {
|
|
1083
|
+
return {
|
|
1084
|
+
activeChunkId,
|
|
1085
|
+
sectionNodes: []
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
const activeNode = (activeChunkId ? graph.nodes.find((node) => node.chunkId === activeChunkId) : undefined) ?? graph.nodes[0];
|
|
1089
|
+
const resolvedActiveChunkId = activeNode?.chunkId;
|
|
1090
|
+
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1091
|
+
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1092
|
+
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1093
|
+
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1094
|
+
return {
|
|
1095
|
+
activeChunkId: resolvedActiveChunkId,
|
|
1096
|
+
activeNode,
|
|
1097
|
+
nextNode,
|
|
1098
|
+
previousNode,
|
|
1099
|
+
section,
|
|
1100
|
+
sectionNodes
|
|
1101
|
+
};
|
|
1102
|
+
};
|
|
889
1103
|
var buildRAGRetrievedState = (messages) => {
|
|
890
1104
|
const message = getLatestRetrievedMessage(messages);
|
|
891
1105
|
if (!message) {
|
|
@@ -920,13 +1134,14 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
920
1134
|
citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
|
|
921
1135
|
citations: groupCitations,
|
|
922
1136
|
chunkIds: group.chunks.map((chunk) => chunk.chunkId),
|
|
923
|
-
contextLabel: buildContextLabel2(leadChunk?.metadata),
|
|
1137
|
+
contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
|
|
924
1138
|
count: group.count,
|
|
925
1139
|
excerpt: buildExcerpt2(leadChunk?.text ?? ""),
|
|
926
1140
|
key: group.key,
|
|
927
1141
|
label: group.label,
|
|
928
|
-
locatorLabel: buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
|
|
929
|
-
provenanceLabel: buildProvenanceLabel2(leadChunk?.metadata),
|
|
1142
|
+
locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
|
|
1143
|
+
provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
|
|
1144
|
+
structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
|
|
930
1145
|
source: group.source,
|
|
931
1146
|
title: group.title
|
|
932
1147
|
};
|
|
@@ -1050,6 +1265,12 @@ var buildSourceGroup = (source, key) => ({
|
|
|
1050
1265
|
count: 1,
|
|
1051
1266
|
key,
|
|
1052
1267
|
label: buildSourceLabel2(source),
|
|
1268
|
+
labels: source.labels ?? buildRAGSourceLabels({
|
|
1269
|
+
metadata: source.metadata,
|
|
1270
|
+
source: source.source,
|
|
1271
|
+
title: source.title
|
|
1272
|
+
}),
|
|
1273
|
+
structure: source.structure ?? buildRAGChunkStructure(source.metadata),
|
|
1053
1274
|
source: source.source,
|
|
1054
1275
|
title: source.title
|
|
1055
1276
|
});
|
|
@@ -1060,7 +1281,20 @@ var updateSourceGroup = (groups, source) => {
|
|
|
1060
1281
|
groups.set(key, buildSourceGroup(source, key));
|
|
1061
1282
|
return;
|
|
1062
1283
|
}
|
|
1063
|
-
|
|
1284
|
+
if (source.score > existing.bestScore) {
|
|
1285
|
+
existing.bestScore = source.score;
|
|
1286
|
+
existing.label = buildSourceLabel2(source);
|
|
1287
|
+
existing.labels = source.labels ?? buildRAGSourceLabels({
|
|
1288
|
+
metadata: source.metadata,
|
|
1289
|
+
source: source.source,
|
|
1290
|
+
title: source.title
|
|
1291
|
+
});
|
|
1292
|
+
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
1293
|
+
existing.source = source.source;
|
|
1294
|
+
existing.title = source.title;
|
|
1295
|
+
} else {
|
|
1296
|
+
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
1297
|
+
}
|
|
1064
1298
|
existing.count += 1;
|
|
1065
1299
|
existing.chunks.push(source);
|
|
1066
1300
|
};
|
|
@@ -1715,6 +1949,10 @@ export {
|
|
|
1715
1949
|
buildRAGComparisonTraceDiffRows,
|
|
1716
1950
|
buildRAGCitations,
|
|
1717
1951
|
buildRAGCitationReferenceMap,
|
|
1952
|
+
buildRAGChunkPreviewNavigation,
|
|
1953
|
+
buildRAGChunkPreviewGraph,
|
|
1954
|
+
buildRAGChunkGraphNavigation,
|
|
1955
|
+
buildRAGChunkGraph,
|
|
1718
1956
|
buildRAGAnswerWorkflowState,
|
|
1719
1957
|
buildRAGAnswerGroundingHistoryRows,
|
|
1720
1958
|
buildRAGAnswerGroundingHistoryPresentation,
|
|
@@ -1725,5 +1963,5 @@ export {
|
|
|
1725
1963
|
buildRAGAdminActionPresentation
|
|
1726
1964
|
};
|
|
1727
1965
|
|
|
1728
|
-
//# debugId=
|
|
1966
|
+
//# debugId=45AD43905031CDB064756E2164756E21
|
|
1729
1967
|
//# sourceMappingURL=ui.js.map
|