@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/index.js
CHANGED
|
@@ -4834,6 +4834,25 @@ var buildContextLabel2 = (metadata) => {
|
|
|
4834
4834
|
if (!metadata) {
|
|
4835
4835
|
return;
|
|
4836
4836
|
}
|
|
4837
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4838
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4839
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4840
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
4841
|
+
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
4842
|
+
return `PDF table block ${sectionTitle}`;
|
|
4843
|
+
}
|
|
4844
|
+
if (pdfTextKind === "paragraph" && sectionTitle) {
|
|
4845
|
+
return `PDF text block ${sectionTitle}`;
|
|
4846
|
+
}
|
|
4847
|
+
if (officeBlockKind === "table" && sectionTitle) {
|
|
4848
|
+
return `Office table block ${sectionTitle}`;
|
|
4849
|
+
}
|
|
4850
|
+
if (officeBlockKind === "list" && sectionTitle) {
|
|
4851
|
+
return `Office list block ${sectionTitle}`;
|
|
4852
|
+
}
|
|
4853
|
+
if (officeBlockKind === "paragraph" && sectionTitle) {
|
|
4854
|
+
return `Office paragraph block ${sectionTitle}`;
|
|
4855
|
+
}
|
|
4837
4856
|
const emailKind = getContextString2(metadata.emailKind);
|
|
4838
4857
|
if (emailKind === "attachment") {
|
|
4839
4858
|
return "Attachment evidence";
|
|
@@ -4870,8 +4889,6 @@ var buildContextLabel2 = (metadata) => {
|
|
|
4870
4889
|
if (speaker) {
|
|
4871
4890
|
return `Speaker ${speaker}`;
|
|
4872
4891
|
}
|
|
4873
|
-
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4874
|
-
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
4875
4892
|
if (sectionTitle) {
|
|
4876
4893
|
return `Section ${sectionTitle}`;
|
|
4877
4894
|
}
|
|
@@ -4881,11 +4898,21 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
4881
4898
|
if (!metadata) {
|
|
4882
4899
|
return;
|
|
4883
4900
|
}
|
|
4901
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4902
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4903
|
+
const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
|
|
4904
|
+
const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
|
|
4884
4905
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
4885
4906
|
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
4886
4907
|
if (page && region) {
|
|
4887
4908
|
return `Page ${page} \xB7 Region ${region}`;
|
|
4888
4909
|
}
|
|
4910
|
+
if (page && pdfBlockNumber && pdfTextKind === "table_like") {
|
|
4911
|
+
return `Page ${page} \xB7 Table Block ${pdfBlockNumber}`;
|
|
4912
|
+
}
|
|
4913
|
+
if (page && pdfBlockNumber) {
|
|
4914
|
+
return `Page ${page} \xB7 Text Block ${pdfBlockNumber}`;
|
|
4915
|
+
}
|
|
4889
4916
|
if (page) {
|
|
4890
4917
|
return `Page ${page}`;
|
|
4891
4918
|
}
|
|
@@ -4914,6 +4941,15 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
4914
4941
|
if (mediaStart) {
|
|
4915
4942
|
return `Timestamp ${mediaStart}`;
|
|
4916
4943
|
}
|
|
4944
|
+
if (officeBlockNumber && officeBlockKind === "table") {
|
|
4945
|
+
return `Office table block ${officeBlockNumber}`;
|
|
4946
|
+
}
|
|
4947
|
+
if (officeBlockNumber && officeBlockKind === "list") {
|
|
4948
|
+
return `Office list block ${officeBlockNumber}`;
|
|
4949
|
+
}
|
|
4950
|
+
if (officeBlockNumber && officeBlockKind === "paragraph") {
|
|
4951
|
+
return `Office paragraph block ${officeBlockNumber}`;
|
|
4952
|
+
}
|
|
4917
4953
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4918
4954
|
if (sectionPath.length > 0) {
|
|
4919
4955
|
return `Section ${sectionPath.join(" > ")}`;
|
|
@@ -4931,12 +4967,16 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
4931
4967
|
const mediaKind = getContextString2(metadata.mediaKind);
|
|
4932
4968
|
const transcriptSource = getContextString2(metadata.transcriptSource);
|
|
4933
4969
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
4970
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4971
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4934
4972
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
4935
4973
|
const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
|
|
4936
4974
|
const chunkingProfile = getContextString2(metadata.chunkingProfile);
|
|
4937
4975
|
const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
|
|
4938
4976
|
const labels = [
|
|
4939
4977
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
4978
|
+
pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
|
|
4979
|
+
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
4940
4980
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
4941
4981
|
extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
|
|
4942
4982
|
chunkingProfile ? `Chunking ${chunkingProfile}` : "",
|
|
@@ -4972,7 +5012,7 @@ var buildRAGChunkStructure = (metadata) => {
|
|
|
4972
5012
|
return;
|
|
4973
5013
|
}
|
|
4974
5014
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
4975
|
-
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;
|
|
5015
|
+
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;
|
|
4976
5016
|
const section = {
|
|
4977
5017
|
depth: getContextNumber2(metadata.sectionDepth),
|
|
4978
5018
|
kind: sectionKind,
|
|
@@ -5292,7 +5332,7 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
5292
5332
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
5293
5333
|
return sourceGroups.map((group) => {
|
|
5294
5334
|
const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
|
|
5295
|
-
const leadChunk = group.chunks
|
|
5335
|
+
const leadChunk = getPreferredSourceLeadChunk(group.chunks);
|
|
5296
5336
|
const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
|
|
5297
5337
|
const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
|
|
5298
5338
|
const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
|
|
@@ -5320,13 +5360,45 @@ var getSectionPathFromSource = (source) => {
|
|
|
5320
5360
|
const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
|
|
5321
5361
|
return path.length > 0 ? path : undefined;
|
|
5322
5362
|
};
|
|
5363
|
+
var isBlockAwareContextLabel = (value) => typeof value === "string" && (value.startsWith("PDF ") || value.startsWith("Office "));
|
|
5364
|
+
var getStructuredSectionScoreWeight = (metadata) => {
|
|
5365
|
+
if (!metadata) {
|
|
5366
|
+
return 1;
|
|
5367
|
+
}
|
|
5368
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
5369
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
5370
|
+
const sectionKind = getContextString2(metadata.sectionKind);
|
|
5371
|
+
if (pdfTextKind === "table_like") {
|
|
5372
|
+
return 1.28;
|
|
5373
|
+
}
|
|
5374
|
+
if (officeBlockKind === "table" || officeBlockKind === "list") {
|
|
5375
|
+
return 1.24;
|
|
5376
|
+
}
|
|
5377
|
+
if (sectionKind === "pdf_block" || sectionKind === "office_block" || officeBlockKind === "paragraph" || pdfTextKind === "paragraph") {
|
|
5378
|
+
return 1.12;
|
|
5379
|
+
}
|
|
5380
|
+
return 1;
|
|
5381
|
+
};
|
|
5382
|
+
var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
5383
|
+
var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
|
|
5384
|
+
const leftWeightedScore = getStructuredSourceLeadScore(left);
|
|
5385
|
+
const rightWeightedScore = getStructuredSourceLeadScore(right);
|
|
5386
|
+
if (rightWeightedScore !== leftWeightedScore) {
|
|
5387
|
+
return rightWeightedScore - leftWeightedScore;
|
|
5388
|
+
}
|
|
5389
|
+
if (right.score !== left.score) {
|
|
5390
|
+
return right.score - left.score;
|
|
5391
|
+
}
|
|
5392
|
+
return left.chunkId.localeCompare(right.chunkId);
|
|
5393
|
+
})[0];
|
|
5323
5394
|
var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
5324
|
-
const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
|
|
5395
|
+
const totalScore = sources.reduce((sum, source) => sum + source.score * getStructuredSectionScoreWeight(source.metadata), 0);
|
|
5325
5396
|
if (sources.length === 0 || totalScore <= 0) {
|
|
5326
5397
|
return [];
|
|
5327
5398
|
}
|
|
5328
5399
|
const sections = new Map;
|
|
5329
5400
|
for (const source of sources) {
|
|
5401
|
+
const structuredScore = source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
5330
5402
|
const path = getSectionPathFromSource(source);
|
|
5331
5403
|
if (!path) {
|
|
5332
5404
|
continue;
|
|
@@ -5358,7 +5430,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5358
5430
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
5359
5431
|
topChunkId: source.chunkId,
|
|
5360
5432
|
topSource: source.source,
|
|
5361
|
-
totalScore:
|
|
5433
|
+
totalScore: structuredScore,
|
|
5362
5434
|
transformedHits,
|
|
5363
5435
|
variantHits,
|
|
5364
5436
|
vectorHits
|
|
@@ -5366,7 +5438,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5366
5438
|
continue;
|
|
5367
5439
|
}
|
|
5368
5440
|
existing.count += 1;
|
|
5369
|
-
existing.totalScore +=
|
|
5441
|
+
existing.totalScore += structuredScore;
|
|
5370
5442
|
if (source.source) {
|
|
5371
5443
|
existing.sourceSet.add(source.source);
|
|
5372
5444
|
}
|
|
@@ -5394,6 +5466,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5394
5466
|
const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
|
|
5395
5467
|
const scoreShare = section.totalScore / totalScore;
|
|
5396
5468
|
const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
|
|
5469
|
+
const topChunk = sources.find((source) => source.chunkId === section.topChunkId);
|
|
5470
|
+
const topContextLabel = topChunk?.labels?.contextLabel ?? buildContextLabel2(topChunk?.metadata);
|
|
5397
5471
|
const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
|
|
5398
5472
|
count: entry.count,
|
|
5399
5473
|
isActive: entry.key === section.key,
|
|
@@ -5519,6 +5593,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
5519
5593
|
reasons.push("concentrated_evidence");
|
|
5520
5594
|
}
|
|
5521
5595
|
const summaryParts = [
|
|
5596
|
+
isBlockAwareContextLabel(topContextLabel) ? topContextLabel : "",
|
|
5522
5597
|
`${section.count} hit${section.count === 1 ? "" : "s"}`,
|
|
5523
5598
|
`${(scoreShare * 100).toFixed(0)}% score share`,
|
|
5524
5599
|
`vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
|
|
@@ -5730,22 +5805,21 @@ var updateSourceGroup = (groups, source) => {
|
|
|
5730
5805
|
groups.set(key, buildSourceGroup(source, key));
|
|
5731
5806
|
return;
|
|
5732
5807
|
}
|
|
5733
|
-
|
|
5734
|
-
existing.bestScore = source.score;
|
|
5735
|
-
existing.label = buildSourceLabel2(source);
|
|
5736
|
-
existing.labels = source.labels ?? buildRAGSourceLabels({
|
|
5737
|
-
metadata: source.metadata,
|
|
5738
|
-
source: source.source,
|
|
5739
|
-
title: source.title
|
|
5740
|
-
});
|
|
5741
|
-
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
5742
|
-
existing.source = source.source;
|
|
5743
|
-
existing.title = source.title;
|
|
5744
|
-
} else {
|
|
5745
|
-
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
5746
|
-
}
|
|
5808
|
+
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
5747
5809
|
existing.count += 1;
|
|
5748
5810
|
existing.chunks.push(source);
|
|
5811
|
+
const leadChunk = getPreferredSourceLeadChunk(existing.chunks);
|
|
5812
|
+
if (leadChunk) {
|
|
5813
|
+
existing.label = buildSourceLabel2(leadChunk);
|
|
5814
|
+
existing.labels = leadChunk.labels ?? buildRAGSourceLabels({
|
|
5815
|
+
metadata: leadChunk.metadata,
|
|
5816
|
+
source: leadChunk.source,
|
|
5817
|
+
title: leadChunk.title
|
|
5818
|
+
});
|
|
5819
|
+
existing.structure = leadChunk.structure ?? buildRAGChunkStructure(leadChunk.metadata);
|
|
5820
|
+
existing.source = leadChunk.source;
|
|
5821
|
+
existing.title = leadChunk.title;
|
|
5822
|
+
}
|
|
5749
5823
|
};
|
|
5750
5824
|
var getLatestAssistantMessage = (messages) => {
|
|
5751
5825
|
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
@@ -7518,5 +7592,5 @@ export {
|
|
|
7518
7592
|
buildRAGEvaluationLeaderboard
|
|
7519
7593
|
};
|
|
7520
7594
|
|
|
7521
|
-
//# debugId=
|
|
7595
|
+
//# debugId=EFA1619967730BA064756E2164756E21
|
|
7522
7596
|
//# sourceMappingURL=index.js.map
|