@absolutejs/absolute 0.19.0-beta.552 → 0.19.0-beta.553
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 +48 -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 +1 -17
- package/dist/src/vue/ai/useRAG.d.ts +2 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +2 -0
- package/dist/types/ai.d.ts +3 -0
- package/package.json +7 -7
package/dist/ai/index.js
CHANGED
|
@@ -2551,6 +2551,7 @@ var resolveRAGHybridSearchOptions = (retrieval) => {
|
|
|
2551
2551
|
fusionConstant: DEFAULT_FUSION_CONSTANT,
|
|
2552
2552
|
lexicalTopK: undefined,
|
|
2553
2553
|
lexicalWeight: 2,
|
|
2554
|
+
sourceBalanceStrategy: "cap",
|
|
2554
2555
|
mode: "vector",
|
|
2555
2556
|
vectorWeight: 1
|
|
2556
2557
|
};
|
|
@@ -2561,6 +2562,7 @@ var resolveRAGHybridSearchOptions = (retrieval) => {
|
|
|
2561
2562
|
fusionConstant: DEFAULT_FUSION_CONSTANT,
|
|
2562
2563
|
lexicalTopK: undefined,
|
|
2563
2564
|
lexicalWeight: 2,
|
|
2565
|
+
sourceBalanceStrategy: "cap",
|
|
2564
2566
|
mode: retrieval,
|
|
2565
2567
|
vectorWeight: 1
|
|
2566
2568
|
};
|
|
@@ -2572,6 +2574,7 @@ var resolveRAGHybridSearchOptions = (retrieval) => {
|
|
|
2572
2574
|
maxResultsPerSource: typeof retrieval.maxResultsPerSource === "number" ? Math.max(1, Math.floor(retrieval.maxResultsPerSource)) : undefined,
|
|
2573
2575
|
lexicalWeight: Math.max(0, retrieval.lexicalWeight ?? 2),
|
|
2574
2576
|
mode: retrieval.mode ?? "vector",
|
|
2577
|
+
sourceBalanceStrategy: retrieval.sourceBalanceStrategy === "round_robin" ? "round_robin" : "cap",
|
|
2575
2578
|
vectorWeight: Math.max(0, retrieval.vectorWeight ?? 1)
|
|
2576
2579
|
};
|
|
2577
2580
|
};
|
|
@@ -4319,10 +4322,47 @@ var getRAGSourceDiversityKey = (result) => {
|
|
|
4319
4322
|
const documentId = typeof result.metadata?.documentId === "string" ? result.metadata.documentId : undefined;
|
|
4320
4323
|
return result.source ?? documentId ?? result.title ?? result.chunkId;
|
|
4321
4324
|
};
|
|
4322
|
-
var applyRAGSourceDiversity = (results, maxResultsPerSource) => {
|
|
4325
|
+
var applyRAGSourceDiversity = (results, maxResultsPerSource, strategy = "cap") => {
|
|
4323
4326
|
if (typeof maxResultsPerSource !== "number") {
|
|
4324
4327
|
return results;
|
|
4325
4328
|
}
|
|
4329
|
+
if (strategy === "round_robin") {
|
|
4330
|
+
const grouped = new Map;
|
|
4331
|
+
const order = [];
|
|
4332
|
+
for (const result of results) {
|
|
4333
|
+
const key = getRAGSourceDiversityKey(result);
|
|
4334
|
+
const entries = grouped.get(key);
|
|
4335
|
+
if (entries) {
|
|
4336
|
+
entries.push(result);
|
|
4337
|
+
continue;
|
|
4338
|
+
}
|
|
4339
|
+
grouped.set(key, [result]);
|
|
4340
|
+
order.push(key);
|
|
4341
|
+
}
|
|
4342
|
+
const counts2 = new Map;
|
|
4343
|
+
const balanced = [];
|
|
4344
|
+
let remaining = true;
|
|
4345
|
+
while (remaining) {
|
|
4346
|
+
remaining = false;
|
|
4347
|
+
for (const key of order) {
|
|
4348
|
+
const entries = grouped.get(key);
|
|
4349
|
+
if (!entries || entries.length === 0) {
|
|
4350
|
+
continue;
|
|
4351
|
+
}
|
|
4352
|
+
if ((counts2.get(key) ?? 0) >= maxResultsPerSource) {
|
|
4353
|
+
continue;
|
|
4354
|
+
}
|
|
4355
|
+
const next = entries.shift();
|
|
4356
|
+
if (!next) {
|
|
4357
|
+
continue;
|
|
4358
|
+
}
|
|
4359
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
4360
|
+
balanced.push(next);
|
|
4361
|
+
remaining = true;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
return balanced;
|
|
4365
|
+
}
|
|
4326
4366
|
const limited = [];
|
|
4327
4367
|
const counts = new Map;
|
|
4328
4368
|
for (const result of results) {
|
|
@@ -4395,6 +4435,7 @@ var createRAGCollection = (options) => {
|
|
|
4395
4435
|
mode: retrieval.mode,
|
|
4396
4436
|
runLexical,
|
|
4397
4437
|
runVector,
|
|
4438
|
+
sourceBalanceStrategy: retrieval.sourceBalanceStrategy,
|
|
4398
4439
|
topK
|
|
4399
4440
|
},
|
|
4400
4441
|
stage: "input"
|
|
@@ -4509,13 +4550,14 @@ var createRAGCollection = (options) => {
|
|
|
4509
4550
|
},
|
|
4510
4551
|
stage: "rerank"
|
|
4511
4552
|
});
|
|
4512
|
-
const diversified = applyRAGSourceDiversity(reranked, retrieval.maxResultsPerSource);
|
|
4553
|
+
const diversified = applyRAGSourceDiversity(reranked, retrieval.maxResultsPerSource, retrieval.sourceBalanceStrategy);
|
|
4513
4554
|
if (typeof retrieval.maxResultsPerSource === "number") {
|
|
4514
4555
|
steps.push({
|
|
4515
4556
|
count: diversified.length,
|
|
4516
4557
|
label: "Balanced candidates across sources",
|
|
4517
4558
|
metadata: {
|
|
4518
|
-
maxResultsPerSource: retrieval.maxResultsPerSource
|
|
4559
|
+
maxResultsPerSource: retrieval.maxResultsPerSource,
|
|
4560
|
+
strategy: retrieval.sourceBalanceStrategy
|
|
4519
4561
|
},
|
|
4520
4562
|
stage: "source_balance"
|
|
4521
4563
|
});
|
|
@@ -4547,6 +4589,7 @@ var createRAGCollection = (options) => {
|
|
|
4547
4589
|
},
|
|
4548
4590
|
runLexical,
|
|
4549
4591
|
runVector,
|
|
4592
|
+
sourceBalanceStrategy: retrieval.sourceBalanceStrategy,
|
|
4550
4593
|
steps,
|
|
4551
4594
|
topK,
|
|
4552
4595
|
transformedQuery: transformed.query,
|
|
@@ -4590,6 +4633,7 @@ var createRAGCollection = (options) => {
|
|
|
4590
4633
|
runLexical,
|
|
4591
4634
|
runVector,
|
|
4592
4635
|
scoreThreshold,
|
|
4636
|
+
sourceBalanceStrategy: retrieval.sourceBalanceStrategy,
|
|
4593
4637
|
steps,
|
|
4594
4638
|
topK,
|
|
4595
4639
|
transformedQuery: transformed.query,
|
|
@@ -12541,5 +12585,5 @@ export {
|
|
|
12541
12585
|
aiChat
|
|
12542
12586
|
};
|
|
12543
12587
|
|
|
12544
|
-
//# debugId=
|
|
12588
|
+
//# debugId=BD4F3B903BF6366564756E2164756E21
|
|
12545
12589
|
//# sourceMappingURL=index.js.map
|