@absolutejs/absolute 0.19.0-beta.603 → 0.19.0-beta.604

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.
@@ -9,6 +9,7 @@ export type RAGSource = {
9
9
  title?: string;
10
10
  source?: string;
11
11
  metadata?: Record<string, unknown>;
12
+ labels?: RAGSourceLabels;
12
13
  };
13
14
  export type RAGSourceGroup = {
14
15
  key: string;
@@ -18,6 +19,7 @@ export type RAGSourceGroup = {
18
19
  bestScore: number;
19
20
  count: number;
20
21
  chunks: RAGSource[];
22
+ labels?: RAGSourceLabels;
21
23
  };
22
24
  export type RAGCitation = {
23
25
  key: string;
@@ -196,10 +198,21 @@ export type RAGMediaTranscriber = {
196
198
  name: string;
197
199
  transcribe: (input: RAGFileExtractionInput) => RAGMediaTranscriptionResult | Promise<RAGMediaTranscriptionResult>;
198
200
  };
201
+ export type RAGOCRRegion = {
202
+ text: string;
203
+ confidence?: number;
204
+ page?: number;
205
+ x?: number;
206
+ y?: number;
207
+ width?: number;
208
+ height?: number;
209
+ };
199
210
  export type RAGOCRResult = {
200
211
  text: string;
201
212
  title?: string;
202
213
  metadata?: Record<string, unknown>;
214
+ confidence?: number;
215
+ regions?: RAGOCRRegion[];
203
216
  };
204
217
  export type RAGOCRProvider = {
205
218
  name: string;
@@ -387,13 +400,22 @@ export type RAGIndexedDocument = {
387
400
  createdAt?: number;
388
401
  updatedAt?: number;
389
402
  metadata?: Record<string, unknown>;
403
+ labels?: RAGSourceLabels;
390
404
  };
391
405
  export type RAGDocumentChunkPreview = {
392
406
  document: Omit<RAGIndexedDocument, 'text' | 'metadata'> & {
393
407
  metadata?: Record<string, unknown>;
408
+ labels?: RAGSourceLabels;
394
409
  };
395
410
  normalizedText: string;
396
- chunks: RAGDocumentChunk[];
411
+ chunks: Array<RAGDocumentChunk & {
412
+ labels?: RAGSourceLabels;
413
+ }>;
414
+ };
415
+ export type RAGSourceLabels = {
416
+ contextLabel?: string;
417
+ locatorLabel?: string;
418
+ provenanceLabel?: string;
397
419
  };
398
420
  export type RAGBackendDescriptor = {
399
421
  id: string;
@@ -604,6 +626,25 @@ export type RAGCorpusHealth = {
604
626
  staleAfterMs: number;
605
627
  staleDocuments: string[];
606
628
  averageChunksPerDocument: number;
629
+ inspection?: {
630
+ sourceNativeKinds: Record<string, number>;
631
+ documentsWithSourceLabels: number;
632
+ chunksWithSourceLabels: number;
633
+ sampleDocuments: Array<{
634
+ id: string;
635
+ title: string;
636
+ source: string;
637
+ sourceNativeKind?: string;
638
+ labels?: RAGSourceLabels;
639
+ }>;
640
+ sampleChunks: Array<{
641
+ chunkId: string;
642
+ documentId?: string;
643
+ source?: string;
644
+ sourceNativeKind?: string;
645
+ labels?: RAGSourceLabels;
646
+ }>;
647
+ };
607
648
  };
608
649
  export type RAGAdminActionRecord = {
609
650
  id: string;
@@ -216,6 +216,10 @@ var buildContextLabel = (metadata) => {
216
216
  return from ? `Message from ${from}` : "Message evidence";
217
217
  }
218
218
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
219
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
220
+ if (page && region) {
221
+ return `Page ${page} region ${region}`;
222
+ }
219
223
  if (page) {
220
224
  return `Page ${page}`;
221
225
  }
@@ -256,6 +260,10 @@ var buildLocatorLabel = (metadata, source, title) => {
256
260
  return;
257
261
  }
258
262
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
263
+ const region = getContextNumber(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
264
+ if (page && region) {
265
+ return `Page ${page} \xB7 Region ${region}`;
266
+ }
259
267
  if (page) {
260
268
  return `Page ${page}`;
261
269
  }
@@ -308,9 +316,11 @@ var buildProvenanceLabel = (metadata) => {
308
316
  const transcriptSource = getContextString(metadata.transcriptSource);
309
317
  const pdfTextMode = getContextString(metadata.pdfTextMode);
310
318
  const ocrEngine = getContextString(metadata.ocrEngine);
319
+ const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
311
320
  const labels = [
312
321
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
313
322
  ocrEngine ? `OCR ${ocrEngine}` : "",
323
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
314
324
  mediaKind ? `Media ${mediaKind}` : "",
315
325
  transcriptSource ? `Transcript ${transcriptSource}` : "",
316
326
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -3977,6 +3987,10 @@ var buildContextLabel2 = (metadata) => {
3977
3987
  return from ? `Message from ${from}` : "Message evidence";
3978
3988
  }
3979
3989
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
3990
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
3991
+ if (page && region) {
3992
+ return `Page ${page} region ${region}`;
3993
+ }
3980
3994
  if (page) {
3981
3995
  return `Page ${page}`;
3982
3996
  }
@@ -4007,6 +4021,10 @@ var buildLocatorLabel2 = (metadata, source, title) => {
4007
4021
  return;
4008
4022
  }
4009
4023
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
4024
+ const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
4025
+ if (page && region) {
4026
+ return `Page ${page} \xB7 Region ${region}`;
4027
+ }
4010
4028
  if (page) {
4011
4029
  return `Page ${page}`;
4012
4030
  }
@@ -4049,9 +4067,11 @@ var buildProvenanceLabel2 = (metadata) => {
4049
4067
  const transcriptSource = getContextString2(metadata.transcriptSource);
4050
4068
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
4051
4069
  const ocrEngine = getContextString2(metadata.ocrEngine);
4070
+ const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
4052
4071
  const labels = [
4053
4072
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
4054
4073
  ocrEngine ? `OCR ${ocrEngine}` : "",
4074
+ typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
4055
4075
  mediaKind ? `Media ${mediaKind}` : "",
4056
4076
  transcriptSource ? `Transcript ${transcriptSource}` : "",
4057
4077
  threadTopic ? `Thread ${threadTopic}` : "",
@@ -4061,6 +4081,23 @@ var buildProvenanceLabel2 = (metadata) => {
4061
4081
  ].filter((value) => value.length > 0);
4062
4082
  return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
4063
4083
  };
4084
+ var buildRAGSourceLabels = ({
4085
+ metadata,
4086
+ source,
4087
+ title
4088
+ }) => {
4089
+ const contextLabel = buildContextLabel2(metadata);
4090
+ const locatorLabel = buildLocatorLabel2(metadata, source, title);
4091
+ const provenanceLabel = buildProvenanceLabel2(metadata);
4092
+ if (!contextLabel && !locatorLabel && !provenanceLabel) {
4093
+ return;
4094
+ }
4095
+ return {
4096
+ contextLabel,
4097
+ locatorLabel,
4098
+ provenanceLabel
4099
+ };
4100
+ };
4064
4101
  var buildExcerpt2 = (text, maxLength = 160) => {
4065
4102
  const normalized = text.replaceAll(/\s+/g, " ").trim();
4066
4103
  if (normalized.length <= maxLength) {
@@ -4102,13 +4139,13 @@ var buildRAGSourceSummaries = (sources) => {
4102
4139
  citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
4103
4140
  citations: groupCitations,
4104
4141
  chunkIds: group.chunks.map((chunk) => chunk.chunkId),
4105
- contextLabel: buildContextLabel2(leadChunk?.metadata),
4142
+ contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
4106
4143
  count: group.count,
4107
4144
  excerpt: buildExcerpt2(leadChunk?.text ?? ""),
4108
4145
  key: group.key,
4109
4146
  label: group.label,
4110
- locatorLabel: buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
4111
- provenanceLabel: buildProvenanceLabel2(leadChunk?.metadata),
4147
+ locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
4148
+ provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
4112
4149
  source: group.source,
4113
4150
  title: group.title
4114
4151
  };
@@ -4232,6 +4269,11 @@ var buildSourceGroup = (source, key) => ({
4232
4269
  count: 1,
4233
4270
  key,
4234
4271
  label: buildSourceLabel2(source),
4272
+ labels: source.labels ?? buildRAGSourceLabels({
4273
+ metadata: source.metadata,
4274
+ source: source.source,
4275
+ title: source.title
4276
+ }),
4235
4277
  source: source.source,
4236
4278
  title: source.title
4237
4279
  });
@@ -4242,7 +4284,19 @@ var updateSourceGroup = (groups, source) => {
4242
4284
  groups.set(key, buildSourceGroup(source, key));
4243
4285
  return;
4244
4286
  }
4245
- existing.bestScore = Math.max(existing.bestScore, source.score);
4287
+ if (source.score > existing.bestScore) {
4288
+ existing.bestScore = source.score;
4289
+ existing.label = buildSourceLabel2(source);
4290
+ existing.labels = source.labels ?? buildRAGSourceLabels({
4291
+ metadata: source.metadata,
4292
+ source: source.source,
4293
+ title: source.title
4294
+ });
4295
+ existing.source = source.source;
4296
+ existing.title = source.title;
4297
+ } else {
4298
+ existing.bestScore = Math.max(existing.bestScore, source.score);
4299
+ }
4246
4300
  existing.count += 1;
4247
4301
  existing.chunks.push(source);
4248
4302
  };
@@ -7313,5 +7367,5 @@ export {
7313
7367
  AIStreamKey
7314
7368
  };
7315
7369
 
7316
- //# debugId=D90380A771DF091664756E2164756E21
7370
+ //# debugId=B9389B1DE37A071364756E2164756E21
7317
7371
  //# sourceMappingURL=index.js.map