@tencent-rtc/mcp 1.6.5 → 1.6.6
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/knowledge/search/exact-lookup.js +15 -10
- package/knowledge/search/search-knowledge.js +14 -5
- package/package.json +1 -1
- package/resource/index/manifest.json +1 -1
- package/resource/knowledge/chat/urls/sdk/android.md +3 -3
- package/resource/knowledge/chat/urls/sdk/flutter.md +3 -3
- package/resource/knowledge/chat/urls/sdk/ios.md +3 -3
- package/resource/knowledge/chat/urls/sdk/web.md +3 -3
- package/server.js +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -319,6 +319,7 @@ const LIVE_LIFECYCLE_APIS = ['createLive', 'endLive', 'joinLive', 'leaveLive'];
|
|
|
319
319
|
export function runExactLookup(prompt, pool, norm) {
|
|
320
320
|
const boosts = {};
|
|
321
321
|
const exactHits = [];
|
|
322
|
+
const urlRowHitChunkIds = new Set();
|
|
322
323
|
const lowerPrompt = prompt.toLowerCase();
|
|
323
324
|
const addBoost = (chunk, amount, label) => {
|
|
324
325
|
boosts[chunk.id] = (boosts[chunk.id] ?? 0) + amount;
|
|
@@ -484,7 +485,7 @@ export function runExactLookup(prompt, pool, norm) {
|
|
|
484
485
|
}
|
|
485
486
|
}
|
|
486
487
|
}
|
|
487
|
-
// E7: URL map row match (chunk.title = Query column; boost
|
|
488
|
+
// E7: URL map row match (chunk.title = Query column); boost multiple strong hits with pinned relaxation
|
|
488
489
|
if (normalizeE7Text(prompt).replace(/\s+/g, '').length >= 2) {
|
|
489
490
|
const candidates = [];
|
|
490
491
|
for (const chunk of pool) {
|
|
@@ -498,14 +499,18 @@ export function runExactLookup(prompt, pool, norm) {
|
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
candidates.sort((a, b) => b.score - a.score);
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
const strongCandidates = candidates
|
|
503
|
+
.filter(({ score }) => score >= 150)
|
|
504
|
+
.slice(0, 12);
|
|
505
|
+
strongCandidates.forEach(({ chunk, score }, idx) => {
|
|
506
|
+
const amount = idx === 0
|
|
507
|
+
? 200 + Math.min(score, 100)
|
|
508
|
+
: idx === 1
|
|
509
|
+
? 170 + Math.min(score, 90)
|
|
510
|
+
: Math.max(score >= 300 ? 100 : 70, 100 - idx * 5);
|
|
511
|
+
addBoost(chunk, amount, `E7:url-row:${chunk.title}`);
|
|
512
|
+
urlRowHitChunkIds.add(chunk.id);
|
|
513
|
+
});
|
|
509
514
|
}
|
|
510
515
|
}
|
|
511
516
|
// E8: 集成查阅意图 boost——prompt 含集成/接入/快速开始/接入文档等意图词时,
|
|
@@ -646,5 +651,5 @@ export function runExactLookup(prompt, pool, norm) {
|
|
|
646
651
|
}
|
|
647
652
|
}
|
|
648
653
|
}
|
|
649
|
-
return { boosts, exactHits };
|
|
654
|
+
return { boosts, exactHits, urlRowHitChunkIds: [...urlRowHitChunkIds] };
|
|
650
655
|
}
|
|
@@ -23,7 +23,7 @@ function loadManifest() {
|
|
|
23
23
|
cachedManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
24
24
|
return cachedManifest;
|
|
25
25
|
}
|
|
26
|
-
function postProcess(ranked, chunksById, limit) {
|
|
26
|
+
function postProcess(ranked, chunksById, limit, opts) {
|
|
27
27
|
const sourceCount = {};
|
|
28
28
|
const urlMappingSourceCount = {};
|
|
29
29
|
/** 已入选的 push config/android/{vendor} 文件,用于抑制其他厂商噪声 */
|
|
@@ -34,9 +34,10 @@ function postProcess(ranked, chunksById, limit) {
|
|
|
34
34
|
if (!chunk)
|
|
35
35
|
continue;
|
|
36
36
|
const isUrlMapping = Boolean(isUrlMappingSource(chunk.source));
|
|
37
|
+
const isPinnedUrlRow = isUrlMapping && (opts?.pinnedUrlRowChunkIds?.has(chunk.id) ?? false);
|
|
37
38
|
if (isUrlMapping) {
|
|
38
39
|
const urlCount = urlMappingSourceCount[chunk.source] ?? 0;
|
|
39
|
-
if (urlCount >= 1)
|
|
40
|
+
if (!isPinnedUrlRow && urlCount >= 1)
|
|
40
41
|
continue;
|
|
41
42
|
urlMappingSourceCount[chunk.source] = urlCount + 1;
|
|
42
43
|
}
|
|
@@ -68,8 +69,9 @@ function postProcess(ranked, chunksById, limit) {
|
|
|
68
69
|
if (firstPush) {
|
|
69
70
|
// 首条不设分数截止,至少保证 1 条返回
|
|
70
71
|
}
|
|
71
|
-
else {
|
|
72
|
+
else if (!isPinnedUrlRow) {
|
|
72
73
|
// 分数衰减到 top 的 5% 以下时停止,不硬填到 limit
|
|
74
|
+
// chat/urls 的行级精确命中(E7)不受该规则截断,保证多子主题可并行返回
|
|
73
75
|
const topScore = fragments[0].score;
|
|
74
76
|
if (topScore > 0 && item.score < topScore * 0.05)
|
|
75
77
|
break;
|
|
@@ -311,7 +313,7 @@ export function searchKnowledge(params) {
|
|
|
311
313
|
if (pool.length === 0 && passNorm.types?.length) {
|
|
312
314
|
pool = filterPool(allChunks, { ...passNorm, types: undefined });
|
|
313
315
|
}
|
|
314
|
-
const { boosts, exactHits } = runExactLookup(passNorm.prompt, pool, passNorm);
|
|
316
|
+
const { boosts, exactHits, urlRowHitChunkIds } = runExactLookup(passNorm.prompt, pool, passNorm);
|
|
315
317
|
// A2 补充正向路由:UserSig 问法下允许 share 命中且优先于无关 urls 噪声
|
|
316
318
|
if (/usersig|sdkappid|secretkey|鉴权|签名|gentestusersig/i.test(passNorm.prompt)) {
|
|
317
319
|
for (const chunk of pool) {
|
|
@@ -337,7 +339,10 @@ export function searchKnowledge(params) {
|
|
|
337
339
|
framework: passNorm.framework,
|
|
338
340
|
frameworks: passNorm.frameworks,
|
|
339
341
|
});
|
|
340
|
-
const
|
|
342
|
+
const pinnedUrlRowChunkIds = new Set(urlRowHitChunkIds);
|
|
343
|
+
const fragments = postProcess(rankedWithMultipliers, chunksById, passNorm.limit, {
|
|
344
|
+
pinnedUrlRowChunkIds,
|
|
345
|
+
});
|
|
341
346
|
const urlMappingSources = [...new Set(fragments.map((f) => f.source).filter((source) => isUrlMappingSource(source)))];
|
|
342
347
|
const references = buildReferences(fragments);
|
|
343
348
|
const apiNameCoverage = computeApiNameCoverage(queryApiTokens, poolWithContent);
|
|
@@ -350,6 +355,8 @@ export function searchKnowledge(params) {
|
|
|
350
355
|
references,
|
|
351
356
|
apiNameCoverage,
|
|
352
357
|
missingApiTokens,
|
|
358
|
+
urlMapRelaxed: pinnedUrlRowChunkIds.size > 0,
|
|
359
|
+
urlMapExactHitCount: pinnedUrlRowChunkIds.size,
|
|
353
360
|
};
|
|
354
361
|
};
|
|
355
362
|
let pass = runSearchPass(norm);
|
|
@@ -389,6 +396,8 @@ export function searchKnowledge(params) {
|
|
|
389
396
|
filtered_size: pass.pool.length,
|
|
390
397
|
exact_hits: pass.exactHits,
|
|
391
398
|
...(pass.urlMappingSources.length ? { url_mapping_sources: pass.urlMappingSources } : {}),
|
|
399
|
+
...(pass.urlMapRelaxed ? { url_map_relaxed: pass.urlMapRelaxed } : {}),
|
|
400
|
+
...(pass.urlMapExactHitCount > 0 ? { url_map_exact_hit_count: pass.urlMapExactHitCount } : {}),
|
|
392
401
|
...(pass.references.length ? { references: pass.references } : {}),
|
|
393
402
|
...(topScore !== undefined ? { top_score: Number(topScore.toFixed(2)) } : {}),
|
|
394
403
|
...(secondScore !== undefined ? { second_score: Number(secondScore.toFixed(2)) } : {}),
|