@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/react/ai/index.js
CHANGED
|
@@ -4237,6 +4237,25 @@ var buildContextLabel2 = (metadata) => {
|
|
|
4237
4237
|
if (!metadata) {
|
|
4238
4238
|
return;
|
|
4239
4239
|
}
|
|
4240
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4241
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4242
|
+
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4243
|
+
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
4244
|
+
if (pdfTextKind === "table_like" && sectionTitle) {
|
|
4245
|
+
return `PDF table block ${sectionTitle}`;
|
|
4246
|
+
}
|
|
4247
|
+
if (pdfTextKind === "paragraph" && sectionTitle) {
|
|
4248
|
+
return `PDF text block ${sectionTitle}`;
|
|
4249
|
+
}
|
|
4250
|
+
if (officeBlockKind === "table" && sectionTitle) {
|
|
4251
|
+
return `Office table block ${sectionTitle}`;
|
|
4252
|
+
}
|
|
4253
|
+
if (officeBlockKind === "list" && sectionTitle) {
|
|
4254
|
+
return `Office list block ${sectionTitle}`;
|
|
4255
|
+
}
|
|
4256
|
+
if (officeBlockKind === "paragraph" && sectionTitle) {
|
|
4257
|
+
return `Office paragraph block ${sectionTitle}`;
|
|
4258
|
+
}
|
|
4240
4259
|
const emailKind = getContextString2(metadata.emailKind);
|
|
4241
4260
|
if (emailKind === "attachment") {
|
|
4242
4261
|
return "Attachment evidence";
|
|
@@ -4273,8 +4292,6 @@ var buildContextLabel2 = (metadata) => {
|
|
|
4273
4292
|
if (speaker) {
|
|
4274
4293
|
return `Speaker ${speaker}`;
|
|
4275
4294
|
}
|
|
4276
|
-
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4277
|
-
const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
|
|
4278
4295
|
if (sectionTitle) {
|
|
4279
4296
|
return `Section ${sectionTitle}`;
|
|
4280
4297
|
}
|
|
@@ -4284,11 +4301,21 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
4284
4301
|
if (!metadata) {
|
|
4285
4302
|
return;
|
|
4286
4303
|
}
|
|
4304
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4305
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4306
|
+
const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
|
|
4307
|
+
const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
|
|
4287
4308
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
4288
4309
|
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
4289
4310
|
if (page && region) {
|
|
4290
4311
|
return `Page ${page} \xB7 Region ${region}`;
|
|
4291
4312
|
}
|
|
4313
|
+
if (page && pdfBlockNumber && pdfTextKind === "table_like") {
|
|
4314
|
+
return `Page ${page} \xB7 Table Block ${pdfBlockNumber}`;
|
|
4315
|
+
}
|
|
4316
|
+
if (page && pdfBlockNumber) {
|
|
4317
|
+
return `Page ${page} \xB7 Text Block ${pdfBlockNumber}`;
|
|
4318
|
+
}
|
|
4292
4319
|
if (page) {
|
|
4293
4320
|
return `Page ${page}`;
|
|
4294
4321
|
}
|
|
@@ -4317,6 +4344,15 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
4317
4344
|
if (mediaStart) {
|
|
4318
4345
|
return `Timestamp ${mediaStart}`;
|
|
4319
4346
|
}
|
|
4347
|
+
if (officeBlockNumber && officeBlockKind === "table") {
|
|
4348
|
+
return `Office table block ${officeBlockNumber}`;
|
|
4349
|
+
}
|
|
4350
|
+
if (officeBlockNumber && officeBlockKind === "list") {
|
|
4351
|
+
return `Office list block ${officeBlockNumber}`;
|
|
4352
|
+
}
|
|
4353
|
+
if (officeBlockNumber && officeBlockKind === "paragraph") {
|
|
4354
|
+
return `Office paragraph block ${officeBlockNumber}`;
|
|
4355
|
+
}
|
|
4320
4356
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
|
|
4321
4357
|
if (sectionPath.length > 0) {
|
|
4322
4358
|
return `Section ${sectionPath.join(" > ")}`;
|
|
@@ -4334,12 +4370,16 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
4334
4370
|
const mediaKind = getContextString2(metadata.mediaKind);
|
|
4335
4371
|
const transcriptSource = getContextString2(metadata.transcriptSource);
|
|
4336
4372
|
const pdfTextMode = getContextString2(metadata.pdfTextMode);
|
|
4373
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4374
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4337
4375
|
const ocrEngine = getContextString2(metadata.ocrEngine);
|
|
4338
4376
|
const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
|
|
4339
4377
|
const chunkingProfile = getContextString2(metadata.chunkingProfile);
|
|
4340
4378
|
const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
|
|
4341
4379
|
const labels = [
|
|
4342
4380
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
4381
|
+
pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
|
|
4382
|
+
officeBlockKind ? `Office ${officeBlockKind}` : "",
|
|
4343
4383
|
ocrEngine ? `OCR ${ocrEngine}` : "",
|
|
4344
4384
|
extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
|
|
4345
4385
|
chunkingProfile ? `Chunking ${chunkingProfile}` : "",
|
|
@@ -4375,7 +4415,7 @@ var buildRAGChunkStructure = (metadata) => {
|
|
|
4375
4415
|
return;
|
|
4376
4416
|
}
|
|
4377
4417
|
const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
|
|
4378
|
-
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;
|
|
4418
|
+
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;
|
|
4379
4419
|
const section = {
|
|
4380
4420
|
depth: getContextNumber2(metadata.sectionDepth),
|
|
4381
4421
|
kind: sectionKind,
|
|
@@ -4695,7 +4735,7 @@ var buildRAGSourceSummaries = (sources) => {
|
|
|
4695
4735
|
const citationReferenceMap = buildRAGCitationReferenceMap(citations);
|
|
4696
4736
|
return sourceGroups.map((group) => {
|
|
4697
4737
|
const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
|
|
4698
|
-
const leadChunk = group.chunks
|
|
4738
|
+
const leadChunk = getPreferredSourceLeadChunk(group.chunks);
|
|
4699
4739
|
const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
|
|
4700
4740
|
const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
|
|
4701
4741
|
const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
|
|
@@ -4723,13 +4763,45 @@ var getSectionPathFromSource = (source) => {
|
|
|
4723
4763
|
const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
|
|
4724
4764
|
return path.length > 0 ? path : undefined;
|
|
4725
4765
|
};
|
|
4766
|
+
var isBlockAwareContextLabel = (value) => typeof value === "string" && (value.startsWith("PDF ") || value.startsWith("Office "));
|
|
4767
|
+
var getStructuredSectionScoreWeight = (metadata) => {
|
|
4768
|
+
if (!metadata) {
|
|
4769
|
+
return 1;
|
|
4770
|
+
}
|
|
4771
|
+
const pdfTextKind = getContextString2(metadata.pdfTextKind);
|
|
4772
|
+
const officeBlockKind = getContextString2(metadata.officeBlockKind);
|
|
4773
|
+
const sectionKind = getContextString2(metadata.sectionKind);
|
|
4774
|
+
if (pdfTextKind === "table_like") {
|
|
4775
|
+
return 1.28;
|
|
4776
|
+
}
|
|
4777
|
+
if (officeBlockKind === "table" || officeBlockKind === "list") {
|
|
4778
|
+
return 1.24;
|
|
4779
|
+
}
|
|
4780
|
+
if (sectionKind === "pdf_block" || sectionKind === "office_block" || officeBlockKind === "paragraph" || pdfTextKind === "paragraph") {
|
|
4781
|
+
return 1.12;
|
|
4782
|
+
}
|
|
4783
|
+
return 1;
|
|
4784
|
+
};
|
|
4785
|
+
var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
4786
|
+
var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
|
|
4787
|
+
const leftWeightedScore = getStructuredSourceLeadScore(left);
|
|
4788
|
+
const rightWeightedScore = getStructuredSourceLeadScore(right);
|
|
4789
|
+
if (rightWeightedScore !== leftWeightedScore) {
|
|
4790
|
+
return rightWeightedScore - leftWeightedScore;
|
|
4791
|
+
}
|
|
4792
|
+
if (right.score !== left.score) {
|
|
4793
|
+
return right.score - left.score;
|
|
4794
|
+
}
|
|
4795
|
+
return left.chunkId.localeCompare(right.chunkId);
|
|
4796
|
+
})[0];
|
|
4726
4797
|
var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
4727
|
-
const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
|
|
4798
|
+
const totalScore = sources.reduce((sum, source) => sum + source.score * getStructuredSectionScoreWeight(source.metadata), 0);
|
|
4728
4799
|
if (sources.length === 0 || totalScore <= 0) {
|
|
4729
4800
|
return [];
|
|
4730
4801
|
}
|
|
4731
4802
|
const sections = new Map;
|
|
4732
4803
|
for (const source of sources) {
|
|
4804
|
+
const structuredScore = source.score * getStructuredSectionScoreWeight(source.metadata);
|
|
4733
4805
|
const path = getSectionPathFromSource(source);
|
|
4734
4806
|
if (!path) {
|
|
4735
4807
|
continue;
|
|
@@ -4761,7 +4833,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4761
4833
|
sourceSet: new Set(source.source ? [source.source] : []),
|
|
4762
4834
|
topChunkId: source.chunkId,
|
|
4763
4835
|
topSource: source.source,
|
|
4764
|
-
totalScore:
|
|
4836
|
+
totalScore: structuredScore,
|
|
4765
4837
|
transformedHits,
|
|
4766
4838
|
variantHits,
|
|
4767
4839
|
vectorHits
|
|
@@ -4769,7 +4841,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4769
4841
|
continue;
|
|
4770
4842
|
}
|
|
4771
4843
|
existing.count += 1;
|
|
4772
|
-
existing.totalScore +=
|
|
4844
|
+
existing.totalScore += structuredScore;
|
|
4773
4845
|
if (source.source) {
|
|
4774
4846
|
existing.sourceSet.add(source.source);
|
|
4775
4847
|
}
|
|
@@ -4797,6 +4869,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4797
4869
|
const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
|
|
4798
4870
|
const scoreShare = section.totalScore / totalScore;
|
|
4799
4871
|
const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
|
|
4872
|
+
const topChunk = sources.find((source) => source.chunkId === section.topChunkId);
|
|
4873
|
+
const topContextLabel = topChunk?.labels?.contextLabel ?? buildContextLabel2(topChunk?.metadata);
|
|
4800
4874
|
const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
|
|
4801
4875
|
count: entry.count,
|
|
4802
4876
|
isActive: entry.key === section.key,
|
|
@@ -4922,6 +4996,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
4922
4996
|
reasons.push("concentrated_evidence");
|
|
4923
4997
|
}
|
|
4924
4998
|
const summaryParts = [
|
|
4999
|
+
isBlockAwareContextLabel(topContextLabel) ? topContextLabel : "",
|
|
4925
5000
|
`${section.count} hit${section.count === 1 ? "" : "s"}`,
|
|
4926
5001
|
`${(scoreShare * 100).toFixed(0)}% score share`,
|
|
4927
5002
|
`vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
|
|
@@ -5133,22 +5208,21 @@ var updateSourceGroup = (groups, source) => {
|
|
|
5133
5208
|
groups.set(key, buildSourceGroup(source, key));
|
|
5134
5209
|
return;
|
|
5135
5210
|
}
|
|
5136
|
-
|
|
5137
|
-
existing.bestScore = source.score;
|
|
5138
|
-
existing.label = buildSourceLabel2(source);
|
|
5139
|
-
existing.labels = source.labels ?? buildRAGSourceLabels({
|
|
5140
|
-
metadata: source.metadata,
|
|
5141
|
-
source: source.source,
|
|
5142
|
-
title: source.title
|
|
5143
|
-
});
|
|
5144
|
-
existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
|
|
5145
|
-
existing.source = source.source;
|
|
5146
|
-
existing.title = source.title;
|
|
5147
|
-
} else {
|
|
5148
|
-
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
5149
|
-
}
|
|
5211
|
+
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
5150
5212
|
existing.count += 1;
|
|
5151
5213
|
existing.chunks.push(source);
|
|
5214
|
+
const leadChunk = getPreferredSourceLeadChunk(existing.chunks);
|
|
5215
|
+
if (leadChunk) {
|
|
5216
|
+
existing.label = buildSourceLabel2(leadChunk);
|
|
5217
|
+
existing.labels = leadChunk.labels ?? buildRAGSourceLabels({
|
|
5218
|
+
metadata: leadChunk.metadata,
|
|
5219
|
+
source: leadChunk.source,
|
|
5220
|
+
title: leadChunk.title
|
|
5221
|
+
});
|
|
5222
|
+
existing.structure = leadChunk.structure ?? buildRAGChunkStructure(leadChunk.metadata);
|
|
5223
|
+
existing.source = leadChunk.source;
|
|
5224
|
+
existing.title = leadChunk.title;
|
|
5225
|
+
}
|
|
5152
5226
|
};
|
|
5153
5227
|
var getLatestAssistantMessage = (messages) => {
|
|
5154
5228
|
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
@@ -8503,5 +8577,5 @@ export {
|
|
|
8503
8577
|
AIStreamProvider
|
|
8504
8578
|
};
|
|
8505
8579
|
|
|
8506
|
-
//# debugId=
|
|
8580
|
+
//# debugId=E2A44B91D70C256864756E2164756E21
|
|
8507
8581
|
//# sourceMappingURL=index.js.map
|