@absolutejs/absolute 0.19.0-beta.527 → 0.19.0-beta.529

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.
@@ -99,6 +99,7 @@ export type RAGRetrievedState = {
99
99
  retrievalStartedAt?: number;
100
100
  retrievedAt?: number;
101
101
  retrievalDurationMs?: number;
102
+ trace?: RAGRetrievalTrace;
102
103
  sources: RAGSource[];
103
104
  sourceGroups: RAGSourceGroup[];
104
105
  sourceSummaries: RAGSourceSummary[];
@@ -479,7 +480,47 @@ export type RAGCollectionSearchParams = {
479
480
  model?: string;
480
481
  signal?: AbortSignal;
481
482
  };
482
- export type RAGSearchRequest = Omit<RAGCollectionSearchParams, 'signal' | 'rerank'>;
483
+ export type RAGRetrievalTraceStage = 'input' | 'query_transform' | 'embed' | 'vector_search' | 'lexical_search' | 'fusion' | 'rerank' | 'score_filter' | 'finalize';
484
+ export type RAGRetrievalTraceStep = {
485
+ stage: RAGRetrievalTraceStage;
486
+ label: string;
487
+ durationMs?: number;
488
+ count?: number;
489
+ metadata?: Record<string, string | number | boolean | null>;
490
+ };
491
+ export type RAGRetrievalTrace = {
492
+ query: string;
493
+ transformedQuery: string;
494
+ variantQueries: string[];
495
+ topK: number;
496
+ candidateTopK: number;
497
+ lexicalTopK: number;
498
+ mode: RAGHybridRetrievalMode;
499
+ runVector: boolean;
500
+ runLexical: boolean;
501
+ scoreThreshold?: number;
502
+ resultCounts: {
503
+ vector: number;
504
+ lexical: number;
505
+ fused: number;
506
+ reranked: number;
507
+ final: number;
508
+ };
509
+ steps: RAGRetrievalTraceStep[];
510
+ };
511
+ export type RAGCollectionSearchResult = {
512
+ results: RAGQueryResult[];
513
+ trace: RAGRetrievalTrace;
514
+ };
515
+ export type RAGSearchRequest = Omit<RAGCollectionSearchParams, 'signal' | 'rerank'> & {
516
+ includeTrace?: boolean;
517
+ };
518
+ export type RAGSearchResponse = {
519
+ ok: boolean;
520
+ results?: RAGSource[];
521
+ trace?: RAGRetrievalTrace;
522
+ error?: string;
523
+ };
483
524
  export type RAGIngestResponse = {
484
525
  ok: boolean;
485
526
  count?: number;
@@ -1261,6 +1302,7 @@ export type RAGRetrievalComparison = {
1261
1302
  export type RAGCollection = {
1262
1303
  store: RAGVectorStore;
1263
1304
  search: (input: RAGCollectionSearchParams) => Promise<RAGQueryResult[]>;
1305
+ searchWithTrace: (input: RAGCollectionSearchParams) => Promise<RAGCollectionSearchResult>;
1264
1306
  ingest: (input: RAGUpsertInput) => Promise<void>;
1265
1307
  clear?: () => Promise<void> | void;
1266
1308
  getStatus?: () => RAGVectorStoreStatus;
@@ -1491,6 +1533,7 @@ export type AIMessage = {
1491
1533
  retrievalStartedAt?: number;
1492
1534
  retrievedAt?: number;
1493
1535
  retrievalDurationMs?: number;
1536
+ retrievalTrace?: RAGRetrievalTrace;
1494
1537
  durationMs?: number;
1495
1538
  timestamp: number;
1496
1539
  };
@@ -1702,6 +1745,7 @@ export type RAGChatPluginConfig = AIChatPluginConfig & {
1702
1745
  extractors?: RAGFileExtractor[];
1703
1746
  embedding?: RAGEmbeddingProviderLike;
1704
1747
  embeddingModel?: string;
1748
+ readinessProviderName?: string;
1705
1749
  rerank?: RAGRerankerProviderLike;
1706
1750
  indexManager?: RAGIndexManager;
1707
1751
  topK?: number;
@@ -1027,8 +1027,12 @@ var createRAGClient = (options) => {
1027
1027
  return parseJson(response);
1028
1028
  },
1029
1029
  async search(input) {
1030
+ const result = await this.searchDetailed(input);
1031
+ return result.results;
1032
+ },
1033
+ async searchDetailed(input) {
1030
1034
  const response = await fetchImpl(`${basePath}/search`, {
1031
- body: JSON.stringify(input),
1035
+ body: JSON.stringify({ ...input, includeTrace: true }),
1032
1036
  headers: jsonHeaders,
1033
1037
  method: "POST"
1034
1038
  });
@@ -1039,7 +1043,10 @@ var createRAGClient = (options) => {
1039
1043
  if (!payload.ok) {
1040
1044
  throw new Error(payload.error ?? "RAG search failed");
1041
1045
  }
1042
- return payload.results ?? [];
1046
+ return {
1047
+ results: payload.results ?? [],
1048
+ trace: payload.trace
1049
+ };
1043
1050
  },
1044
1051
  async status() {
1045
1052
  const response = await fetchImpl(`${basePath}/status`);
@@ -1098,6 +1105,13 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
1098
1105
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
1099
1106
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
1100
1107
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
1108
+ var isRAGRetrievalTrace = (value) => {
1109
+ if (!value || typeof value !== "object") {
1110
+ return false;
1111
+ }
1112
+ const candidate = value;
1113
+ return typeof candidate.query === "string" && typeof candidate.transformedQuery === "string" && Array.isArray(candidate.variantQueries) && Array.isArray(candidate.steps);
1114
+ };
1101
1115
  var formatTimestampLabel = (value) => {
1102
1116
  const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
1103
1117
  if (!Number.isFinite(timestamp)) {
@@ -1365,6 +1379,7 @@ var buildRAGRetrievedState = (messages) => {
1365
1379
  retrievalDurationMs: message.retrievalDurationMs,
1366
1380
  retrievalStartedAt: message.retrievalStartedAt,
1367
1381
  retrievedAt: message.retrievedAt,
1382
+ trace: isRAGRetrievalTrace(message.retrievalTrace) ? message.retrievalTrace : undefined,
1368
1383
  sourceGroups: buildRAGSourceGroups(sources),
1369
1384
  sourceSummaries: buildRAGSourceSummaries(sources),
1370
1385
  sources
@@ -3274,5 +3289,5 @@ export {
3274
3289
  AIStreamKey
3275
3290
  };
3276
3291
 
3277
- //# debugId=3DD3557C9D6FE70C64756E2164756E21
3292
+ //# debugId=4CD93E092D2A92E664756E2164756E21
3278
3293
  //# sourceMappingURL=index.js.map