fix: sync bridge HTTP tool deps and product timeout from test deployment
This commit is contained in:
+12
-1
@@ -377,8 +377,19 @@ function createTools(cfg, deps = {}) {
|
||||
const query = String(args.query || '').trim();
|
||||
if (!query) throw new ToolError(400, 'invalid_arguments', 'query is required');
|
||||
const limit = Math.min(Number(args.limit) || 5, 8);
|
||||
let results = await retriever.searchKB(query, Math.max(limit, 8));
|
||||
// 有 reranker 时多取候选再重排;无 reranker 时尊重调用方 limit。
|
||||
const fetchLimit = reranker ? Math.max(limit, 8) : limit;
|
||||
let results = await retriever.searchKB(query, fetchLimit);
|
||||
// parent/child 可能命中同一篇文章:按 question+answer 去重
|
||||
const seen = new Set();
|
||||
results = results.filter((r) => {
|
||||
const key = `${r.question || ''}\u0000${r.answer || ''}`;
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
return true;
|
||||
});
|
||||
if (reranker) results = await reranker.rerank(query, results, limit);
|
||||
else results = results.slice(0, limit);
|
||||
return {
|
||||
results,
|
||||
count: results.length,
|
||||
|
||||
Reference in New Issue
Block a user