@absolutejs/absolute 0.19.0-beta.551 → 0.19.0-beta.552
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/index.js +40 -4
- package/dist/ai/index.js.map +4 -4
- 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/src/ai/rag/lexical.d.ts +9 -0
- package/dist/src/vue/ai/useRAG.d.ts +8 -0
- package/dist/src/vue/ai/useRAGEvaluate.d.ts +6 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +2 -0
- package/dist/types/ai.d.ts +3 -1
- package/package.json +7 -7
package/dist/ai/index.js
CHANGED
|
@@ -2569,6 +2569,7 @@ var resolveRAGHybridSearchOptions = (retrieval) => {
|
|
|
2569
2569
|
fusion: retrieval.fusion ?? "rrf",
|
|
2570
2570
|
fusionConstant: Math.max(1, Math.floor(retrieval.fusionConstant ?? DEFAULT_FUSION_CONSTANT)),
|
|
2571
2571
|
lexicalTopK: retrieval.lexicalTopK,
|
|
2572
|
+
maxResultsPerSource: typeof retrieval.maxResultsPerSource === "number" ? Math.max(1, Math.floor(retrieval.maxResultsPerSource)) : undefined,
|
|
2572
2573
|
lexicalWeight: Math.max(0, retrieval.lexicalWeight ?? 2),
|
|
2573
2574
|
mode: retrieval.mode ?? "vector",
|
|
2574
2575
|
vectorWeight: Math.max(0, retrieval.vectorWeight ?? 1)
|
|
@@ -4314,6 +4315,27 @@ var mergeQueryResults = (results) => {
|
|
|
4314
4315
|
return left.chunkId.localeCompare(right.chunkId);
|
|
4315
4316
|
});
|
|
4316
4317
|
};
|
|
4318
|
+
var getRAGSourceDiversityKey = (result) => {
|
|
4319
|
+
const documentId = typeof result.metadata?.documentId === "string" ? result.metadata.documentId : undefined;
|
|
4320
|
+
return result.source ?? documentId ?? result.title ?? result.chunkId;
|
|
4321
|
+
};
|
|
4322
|
+
var applyRAGSourceDiversity = (results, maxResultsPerSource) => {
|
|
4323
|
+
if (typeof maxResultsPerSource !== "number") {
|
|
4324
|
+
return results;
|
|
4325
|
+
}
|
|
4326
|
+
const limited = [];
|
|
4327
|
+
const counts = new Map;
|
|
4328
|
+
for (const result of results) {
|
|
4329
|
+
const key = getRAGSourceDiversityKey(result);
|
|
4330
|
+
const count = counts.get(key) ?? 0;
|
|
4331
|
+
if (count >= maxResultsPerSource) {
|
|
4332
|
+
continue;
|
|
4333
|
+
}
|
|
4334
|
+
counts.set(key, count + 1);
|
|
4335
|
+
limited.push(result);
|
|
4336
|
+
}
|
|
4337
|
+
return limited;
|
|
4338
|
+
};
|
|
4317
4339
|
var weightQueryResults = (results, queryIndex) => {
|
|
4318
4340
|
if (queryIndex === 0) {
|
|
4319
4341
|
return results;
|
|
@@ -4369,6 +4391,7 @@ var createRAGCollection = (options) => {
|
|
|
4369
4391
|
candidateTopK,
|
|
4370
4392
|
hasQueryTransform,
|
|
4371
4393
|
hasReranker,
|
|
4394
|
+
maxResultsPerSource: retrieval.maxResultsPerSource ?? null,
|
|
4372
4395
|
mode: retrieval.mode,
|
|
4373
4396
|
runLexical,
|
|
4374
4397
|
runVector,
|
|
@@ -4486,7 +4509,18 @@ var createRAGCollection = (options) => {
|
|
|
4486
4509
|
},
|
|
4487
4510
|
stage: "rerank"
|
|
4488
4511
|
});
|
|
4489
|
-
const
|
|
4512
|
+
const diversified = applyRAGSourceDiversity(reranked, retrieval.maxResultsPerSource);
|
|
4513
|
+
if (typeof retrieval.maxResultsPerSource === "number") {
|
|
4514
|
+
steps.push({
|
|
4515
|
+
count: diversified.length,
|
|
4516
|
+
label: "Balanced candidates across sources",
|
|
4517
|
+
metadata: {
|
|
4518
|
+
maxResultsPerSource: retrieval.maxResultsPerSource
|
|
4519
|
+
},
|
|
4520
|
+
stage: "source_balance"
|
|
4521
|
+
});
|
|
4522
|
+
}
|
|
4523
|
+
const limited = diversified.slice(0, topK);
|
|
4490
4524
|
if (typeof input.scoreThreshold !== "number") {
|
|
4491
4525
|
steps.push({
|
|
4492
4526
|
count: limited.length,
|
|
@@ -4501,13 +4535,14 @@ var createRAGCollection = (options) => {
|
|
|
4501
4535
|
trace: {
|
|
4502
4536
|
candidateTopK,
|
|
4503
4537
|
lexicalTopK,
|
|
4538
|
+
maxResultsPerSource: retrieval.maxResultsPerSource,
|
|
4504
4539
|
mode: retrieval.mode,
|
|
4505
4540
|
query: input.query,
|
|
4506
4541
|
resultCounts: {
|
|
4507
4542
|
final: limited.length,
|
|
4508
4543
|
fused: results.length,
|
|
4509
4544
|
lexical: lexicalResults.length,
|
|
4510
|
-
reranked:
|
|
4545
|
+
reranked: diversified.length,
|
|
4511
4546
|
vector: vectorResults.length
|
|
4512
4547
|
},
|
|
4513
4548
|
runLexical,
|
|
@@ -4542,13 +4577,14 @@ var createRAGCollection = (options) => {
|
|
|
4542
4577
|
trace: {
|
|
4543
4578
|
candidateTopK,
|
|
4544
4579
|
lexicalTopK,
|
|
4580
|
+
maxResultsPerSource: retrieval.maxResultsPerSource,
|
|
4545
4581
|
mode: retrieval.mode,
|
|
4546
4582
|
query: input.query,
|
|
4547
4583
|
resultCounts: {
|
|
4548
4584
|
final: filtered.length,
|
|
4549
4585
|
fused: results.length,
|
|
4550
4586
|
lexical: lexicalResults.length,
|
|
4551
|
-
reranked:
|
|
4587
|
+
reranked: diversified.length,
|
|
4552
4588
|
vector: vectorResults.length
|
|
4553
4589
|
},
|
|
4554
4590
|
runLexical,
|
|
@@ -12505,5 +12541,5 @@ export {
|
|
|
12505
12541
|
aiChat
|
|
12506
12542
|
};
|
|
12507
12543
|
|
|
12508
|
-
//# debugId=
|
|
12544
|
+
//# debugId=FD250EE2F99EB57964756E2164756E21
|
|
12509
12545
|
//# sourceMappingURL=index.js.map
|