@absolutejs/absolute 0.19.0-beta.618 → 0.19.0-beta.619
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 +96 -22
- package/dist/ai/client/index.js.map +3 -3
- package/dist/ai/client/ui.js +96 -22
- package/dist/ai/client/ui.js.map +3 -3
- package/dist/ai/index.js +473 -82
- package/dist/ai/index.js.map +7 -7
- package/dist/ai/rag/ui.js +96 -22
- package/dist/ai/rag/ui.js.map +3 -3
- package/dist/ai-client/angular/ai/index.js +95 -21
- package/dist/ai-client/react/ai/index.js +95 -21
- package/dist/ai-client/vue/ai/index.js +95 -21
- package/dist/angular/ai/index.js +96 -22
- package/dist/angular/ai/index.js.map +3 -3
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/server.js +2 -2
- package/dist/angular/server.js.map +1 -1
- package/dist/build.js +2 -2
- package/dist/build.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/ai/index.js +96 -22
- package/dist/react/ai/index.js.map +3 -3
- package/dist/src/vue/ai/useRAG.d.ts +4 -4
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +2 -2
- package/dist/src/vue/ai/useRAGSearch.d.ts +2 -2
- package/dist/svelte/ai/index.js +96 -22
- package/dist/svelte/ai/index.js.map +3 -3
- package/dist/types/ai.d.ts +2 -2
- package/dist/vue/ai/index.js +96 -22
- package/dist/vue/ai/index.js.map +3 -3
- package/package.json +7 -7
package/dist/ai/client/ui.js
CHANGED
|
@@ -1009,6 +1009,25 @@ var buildContextLabel2 = (metadata) => {
|
|
|
1009
1009
|
if (!metadata) {
|
|
1010
1010
|
return;
|
|
1011
1011
|
}
|
|
1012
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
1013
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
1014
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
1015
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
1016
|
+
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
1017
|
+
return `PDF table block ${sectionTitle}`;
|
|
1018
|
+
}
|
|
1019
|
+
if (pdfTextKind === "paragraph" && sectionTitle) {
|
|
1020
|
+
return `PDF text block ${sectionTitle}`;
|
|
1021
|
+
}
|
|
1022
|
+
if (officeBlockKind === "table" && sectionTitle) {
|
|
1023
|
+
return `Office table block ${sectionTitle}`;
|
|
1024
|
+
}
|
|
1025
|
+
if (officeBlockKind === "list" && sectionTitle) {
|
|
1026
|
+
return `Office list block ${sectionTitle}`;
|
|
1027
|
+
}
|
|
1028
|
+
if (officeBlockKind === "paragraph" && sectionTitle) {
|
|
1029
|
+
return `Office paragraph block ${sectionTitle}`;
|
|
1030
|
+
}
|
|
1012
1031
|
const emailKind = getContextString2(metadata.emailKind);
|
|
1013
1032
|
if (emailKind === "attachment") {
|
|
1014
1033
|
return "Attachment evidence";
|
|
@@ -1045,8 +1064,6 @@ var buildContextLabel2 = (metadata) => {
|
|
|
1045
1064
|
if (speaker) {
|
|
1046
1065
|
return `Speaker ${speaker}`;
|
|
1047
1066
|
}
|
|
1048
|
-
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
1049
|
-
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
1050
1067
|
if (sectionTitle) {
|
|
1051
1068
|
return `Section ${sectionTitle}`;
|
|
1052
1069
|
}
|
|
@@ -1056,11 +1073,21 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
1056
1073
|
if (!metadata) {
|
|
1057
1074
|
return;
|
|
1058
1075
|
}
|
|
1076
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
1077
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
1078
|
+
const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
|
|
1079
|
+
const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
|
|
1059
1080
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
1060
1081
|
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
1061
1082
|
if (page && region) {
|
|
1062
1083
|
return `Page ${page} \xB7 Region ${region}`;
|
|
1063
1084
|
}
|
|
1085
|
+
if (page && pdfBlockNumber && pdfTextKind === "table_like") {
|
|
1086
|
+
return `Page ${page} \xB7 Table Block ${pdfBlockNumber}`;
|
|
1087
|
+
}
|
|
1088
|
+
if (page && pdfBlockNumber) {
|
|
1089
|
+
return `Page ${page} \xB7 Text Block ${pdfBlockNumber}`;
|
|
1090
|
+
}
|
|
1064
1091
|
if (page) {
|
|
1065
1092
|
return `Page ${page}`;
|
|
1066
1093
|
}
|
|
@@ -1089,6 +1116,15 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
1089
1116
|
if (mediaStart) {
|
|
1090
1117
|
return `Timestamp ${mediaStart}`;
|
|
1091
1118
|
}
|
|
1119
|
+
if (officeBlockNumber && officeBlockKind === "table") {
|
|
1120
|
+
return `Office table block ${officeBlockNumber}`;
|
|
1121
|
+
}
|
|
1122
|
+
if (officeBlockNumber && officeBlockKind === "list") {
|
|
1123
|
+
return `Office list block ${officeBlockNumber}`;
|
|
1124
|
+
}
|
|
1125
|
+
if (officeBlockNumber && officeBlockKind === "paragraph") {
|
|
1126
|
+
return `Office paragraph block ${officeBlockNumber}`;
|
|
1127
|
+
}
|
|
1092
1128
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
1093
1129
|
if (sectionPath.length > 0) {
|
|
1094
1130
|
return `Section ${sectionPath.join(" > ")}`;
|
|
@@ -1106,12 +1142,16 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
1106
1142
|
const mediaKind = getContextString2(metadata.mediaKind);
|
|
1107
1143
|
const transcriptSource = getContextString2(metadata.transcriptSource);
|
|
1108
1144
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
1145
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
1146
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
1109
1147
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
1110
1148
|
const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
|
|
1111
1149
|
const chunkingProfile = getContextString2(metadata.chunkingProfile);
|
|
1112
1150
|
const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
|
|
1113
1151
|
const labels = [
|
|
1114
1152
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
1153
|
+
pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
|
|
1154
|
+
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
1115
1155
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
1116
1156
|
extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
|
|
1117
1157
|
chunkingProfile ? `Chunking ${chunkingProfile}` : "",
|
|
@@ -1147,7 +1187,7 @@ var buildRAGChunkStructure = (metadata) => {
|
|
|
1147
1187
|
return;
|
|
1148
1188
|
}
|
|
1149
1189
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
1150
|
-
const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" || metadata.sectionKind === "office_heading" || metadata.sectionKind === "spreadsheet_rows" || metadata.sectionKind === "presentation_slide" ? metadata.sectionKind : undefined;
|
|
1190
|
+
const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" || metadata.sectionKind === "office_heading" || metadata.sectionKind === "office_block" || metadata.sectionKind === "pdf_block" || metadata.sectionKind === "spreadsheet_rows" || metadata.sectionKind === "presentation_slide" ? metadata.sectionKind : undefined;
|
|
1151
1191
|
const section = {
|
|
1152
1192
|
depth: getContextNumber2(metadata.sectionDepth),
|
|
1153
1193
|
kind: sectionKind,
|
|
@@ -1467,7 +1507,7 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
1467
1507
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
1468
1508
|
return sourceGroups.map((group) => {
|
|
1469
1509
|
const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
|
|
1470
|
-
const leadChunk = group.chunks
|
|
1510
|
+
const leadChunk = getPreferredSourceLeadChunk(group.chunks);
|
|
1471
1511
|
const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
|
|
1472
1512
|
const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
|
|
1473
1513
|
const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
|
|
@@ -1495,13 +1535,45 @@ var getSectionPathFromSource = (source) => {
|
|
|
1495
1535
|
const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
|
|
1496
1536
|
return path.length > 0 ? path : undefined;
|
|
1497
1537
|
};
|
|
1538
|
+
var isBlockAwareContextLabel = (value) => typeof value === "string" && (value.startsWith("PDF ") || value.startsWith("Office "));
|
|
1539
|
+
var getStructuredSectionScoreWeight = (metadata) => {
|
|
1540
|
+
if (!metadata) {
|
|
1541
|
+
return 1;
|
|
1542
|
+
}
|
|
1543
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
1544
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
1545
|
+
const sectionKind = getContextString2(metadata.sectionKind);
|
|
1546
|
+
if (pdfTextKind === "table_like") {
|
|
1547
|
+
return 1.28;
|
|
1548
|
+
}
|
|
1549
|
+
if (officeBlockKind === "table" || officeBlockKind === "list") {
|
|
1550
|
+
return 1.24;
|
|
1551
|
+
}
|
|
1552
|
+
if (sectionKind === "pdf_block" || sectionKind === "office_block" || officeBlockKind === "paragraph" || pdfTextKind === "paragraph") {
|
|
1553
|
+
return 1.12;
|
|
1554
|
+
}
|
|
1555
|
+
return 1;
|
|
1556
|
+
};
|
|
1557
|
+
var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
1558
|
+
var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
|
|
1559
|
+
const leftWeightedScore = getStructuredSourceLeadScore(left);
|
|
1560
|
+
const rightWeightedScore = getStructuredSourceLeadScore(right);
|
|
1561
|
+
if (rightWeightedScore !== leftWeightedScore) {
|
|
1562
|
+
return rightWeightedScore - leftWeightedScore;
|
|
1563
|
+
}
|
|
1564
|
+
if (right.score !== left.score) {
|
|
1565
|
+
return right.score - left.score;
|
|
1566
|
+
}
|
|
1567
|
+
return left.chunkId.localeCompare(right.chunkId);
|
|
1568
|
+
})[0];
|
|
1498
1569
|
var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
1499
|
-
const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
|
|
1570
|
+
const totalScore = sources.reduce((sum, source) => sum + source.score * getStructuredSectionScoreWeight(source.metadata), 0);
|
|
1500
1571
|
if (sources.length === 0 || totalScore <= 0) {
|
|
1501
1572
|
return [];
|
|
1502
1573
|
}
|
|
1503
1574
|
const sections = new Map;
|
|
1504
1575
|
for (const source of sources) {
|
|
1576
|
+
const structuredScore = source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
1505
1577
|
const path = getSectionPathFromSource(source);
|
|
1506
1578
|
if (!path) {
|
|
1507
1579
|
continue;
|
|
@@ -1533,7 +1605,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1533
1605
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
1534
1606
|
topChunkId: source.chunkId,
|
|
1535
1607
|
topSource: source.source,
|
|
1536
|
-
totalScore:
|
|
1608
|
+
totalScore: structuredScore,
|
|
1537
1609
|
transformedHits,
|
|
1538
1610
|
variantHits,
|
|
1539
1611
|
vectorHits
|
|
@@ -1541,7 +1613,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1541
1613
|
continue;
|
|
1542
1614
|
}
|
|
1543
1615
|
existing.count += 1;
|
|
1544
|
-
existing.totalScore +=
|
|
1616
|
+
existing.totalScore += structuredScore;
|
|
1545
1617
|
if (source.source) {
|
|
1546
1618
|
existing.sourceSet.add(source.source);
|
|
1547
1619
|
}
|
|
@@ -1569,6 +1641,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1569
1641
|
const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
|
|
1570
1642
|
const scoreShare = section.totalScore / totalScore;
|
|
1571
1643
|
const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
|
|
1644
|
+
const topChunk = sources.find((source) => source.chunkId === section.topChunkId);
|
|
1645
|
+
const topContextLabel = topChunk?.labels?.contextLabel ?? buildContextLabel2(topChunk?.metadata);
|
|
1572
1646
|
const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
|
|
1573
1647
|
count: entry.count,
|
|
1574
1648
|
isActive: entry.key === section.key,
|
|
@@ -1694,6 +1768,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
1694
1768
|
reasons.push("concentrated_evidence");
|
|
1695
1769
|
}
|
|
1696
1770
|
const summaryParts = [
|
|
1771
|
+
isBlockAwareContextLabel(topContextLabel) ? topContextLabel : "",
|
|
1697
1772
|
`${section.count} hit${section.count === 1 ? "" : "s"}`,
|
|
1698
1773
|
`${(scoreShare * 100).toFixed(0)}% score share`,
|
|
1699
1774
|
`vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
|
|
@@ -1905,22 +1980,21 @@ var updateSourceGroup = (groups, source) => {
|
|
|
1905
1980
|
groups.set(key, buildSourceGroup(source, key));
|
|
1906
1981
|
return;
|
|
1907
1982
|
}
|
|
1908
|
-
|
|
1909
|
-
existing.bestScore = source.score;
|
|
1910
|
-
existing.label = buildSourceLabel2(source);
|
|
1911
|
-
existing.labels = source.labels ?? buildRAGSourceLabels({
|
|
1912
|
-
metadata: source.metadata,
|
|
1913
|
-
source: source.source,
|
|
1914
|
-
title: source.title
|
|
1915
|
-
});
|
|
1916
|
-
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
1917
|
-
existing.source = source.source;
|
|
1918
|
-
existing.title = source.title;
|
|
1919
|
-
} else {
|
|
1920
|
-
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
1921
|
-
}
|
|
1983
|
+
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
1922
1984
|
existing.count += 1;
|
|
1923
1985
|
existing.chunks.push(source);
|
|
1986
|
+
const leadChunk = getPreferredSourceLeadChunk(existing.chunks);
|
|
1987
|
+
if (leadChunk) {
|
|
1988
|
+
existing.label = buildSourceLabel2(leadChunk);
|
|
1989
|
+
existing.labels = leadChunk.labels ?? buildRAGSourceLabels({
|
|
1990
|
+
metadata: leadChunk.metadata,
|
|
1991
|
+
source: leadChunk.source,
|
|
1992
|
+
title: leadChunk.title
|
|
1993
|
+
});
|
|
1994
|
+
existing.structure = leadChunk.structure ?? buildRAGChunkStructure(leadChunk.metadata);
|
|
1995
|
+
existing.source = leadChunk.source;
|
|
1996
|
+
existing.title = leadChunk.title;
|
|
1997
|
+
}
|
|
1924
1998
|
};
|
|
1925
1999
|
var getLatestAssistantMessage = (messages) => {
|
|
1926
2000
|
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
@@ -2559,5 +2633,5 @@ export {
|
|
|
2559
2633
|
buildRAGAnswerWorkflowState
|
|
2560
2634
|
};
|
|
2561
2635
|
|
|
2562
|
-
//# debugId=
|
|
2636
|
+
//# debugId=9F26052EE0A220C364756E2164756E21
|
|
2563
2637
|
//# sourceMappingURL=ui.js.map
|