@customize-agent/knowledge 4.0.28 → 4.0.29
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.
|
@@ -339,13 +339,16 @@ export class KnowledgeBaseManager {
|
|
|
339
339
|
const limit = options.limit ?? 10;
|
|
340
340
|
const start = Date.now();
|
|
341
341
|
const weights = this.retrievalWeights(options.weights);
|
|
342
|
-
const rewrittenQueries = await this.rewriteQueries(query);
|
|
342
|
+
const rewrittenQueries = options.generationMode ? [query.trim()].filter(Boolean) : await this.rewriteQueries(query);
|
|
343
343
|
const rankedLists = [];
|
|
344
|
+
const keywordMultiplier = options.generationMode ? 2 : 3;
|
|
345
|
+
const vectorMultiplier = options.generationMode ? 3 : 6;
|
|
346
|
+
const vectorQueryLimit = options.generationMode ? 1 : 3;
|
|
344
347
|
for (const [queryIndex, rewritten] of rewrittenQueries.entries()) {
|
|
345
|
-
rankedLists.push({ source: 'keyword', items: this.keywordSearchItems(rewritten, limit *
|
|
346
|
-
if (queryIndex <
|
|
348
|
+
rankedLists.push({ source: 'keyword', items: this.keywordSearchItems(rewritten, limit * keywordMultiplier), queryIndex });
|
|
349
|
+
if (queryIndex < vectorQueryLimit) {
|
|
347
350
|
try {
|
|
348
|
-
rankedLists.push({ source: 'vector', items: (await this.semanticSearch(rewritten, { ...options, limit: limit *
|
|
351
|
+
rankedLists.push({ source: 'vector', items: (await this.semanticSearch(rewritten, { ...options, limit: limit * vectorMultiplier })).results.slice(0, limit * keywordMultiplier), queryIndex });
|
|
349
352
|
}
|
|
350
353
|
catch { /* 向量搜索在混合搜索中是可选的 */ }
|
|
351
354
|
}
|
|
@@ -26,6 +26,8 @@ export declare class MultiProjectManager {
|
|
|
26
26
|
limit?: number;
|
|
27
27
|
scope?: SearchScope;
|
|
28
28
|
weights?: RetrievalWeights;
|
|
29
|
+
generationMode?: boolean;
|
|
30
|
+
skipFreshCheck?: boolean;
|
|
29
31
|
}): Promise<FederatedResult>;
|
|
30
32
|
semanticSearch(projectRoot: string, query: string, options?: {
|
|
31
33
|
limit?: number;
|
|
@@ -64,18 +64,19 @@ export class MultiProjectManager {
|
|
|
64
64
|
const limit = options.limit ?? 10;
|
|
65
65
|
const scope = options.scope ?? 'project';
|
|
66
66
|
const project = await this.getProject(projectRoot);
|
|
67
|
-
|
|
67
|
+
if (!options.skipFreshCheck)
|
|
68
|
+
await this.ensureFreshForSearch(projectRoot, project);
|
|
68
69
|
if (scope === 'project')
|
|
69
|
-
return project.hybridSearch(query, { limit, weights: options.weights });
|
|
70
|
+
return project.hybridSearch(query, { limit, weights: options.weights, generationMode: options.generationMode });
|
|
70
71
|
const projectResults = scope === 'all'
|
|
71
|
-
? await project.hybridSearch(query, { limit, weights: options.weights })
|
|
72
|
+
? await project.hybridSearch(query, { limit, weights: options.weights, generationMode: options.generationMode })
|
|
72
73
|
: { results: [], scopesSearched: [], queryTimeMs: 0 };
|
|
73
74
|
if (scope === 'global') {
|
|
74
75
|
const global = await this.getGlobalKB();
|
|
75
|
-
return global.hybridSearch(query, { limit, weights: options.weights });
|
|
76
|
+
return global.hybridSearch(query, { limit, weights: options.weights, generationMode: options.generationMode });
|
|
76
77
|
}
|
|
77
78
|
const global = await this.getGlobalKB();
|
|
78
|
-
const globalResults = await global.hybridSearch(query, { limit, weights: options.weights });
|
|
79
|
+
const globalResults = await global.hybridSearch(query, { limit, weights: options.weights, generationMode: options.generationMode });
|
|
79
80
|
const merged = new FederationSearch().merge([...projectResults.results, ...globalResults.results], limit, 'all');
|
|
80
81
|
return {
|
|
81
82
|
...merged,
|