feat(rag): align LightRAG native citations and MCP bridge
This commit is contained in:
@@ -81,6 +81,11 @@ async function apiSearch(context) {
|
||||
const payload = await response.json();
|
||||
const results = Array.isArray(payload.results) ? payload.results : [];
|
||||
assert(results.length >= TOP_N, `资料库结果不足 ${TOP_N} 条: ${JSON.stringify(payload, null, 2).slice(0, 3000)}`);
|
||||
assert(Array.isArray(payload.citations) && payload.citations.length >= TOP_N, `资料库结果缺少 citations[]: ${JSON.stringify(payload, null, 2).slice(0, 3000)}`);
|
||||
results.slice(0, TOP_N).forEach((item, index) => {
|
||||
assert(item.displayQuote && item.locatorEvidenceText, `第 ${index + 1} 条缺少 displayQuote/locatorEvidenceText: ${JSON.stringify(item, null, 2)}`);
|
||||
assert(!/(?:<\/?e(?:q(?:uation)?)?\b|<\/?drawing\b|format=["']?latex|\blatex\b)/i.test(String(item.displayQuote || "")), `第 ${index + 1} 条 displayQuote 仍暴露原始公式/绘图标记: ${item.displayQuote}`);
|
||||
});
|
||||
const blockIds = results.map((item) => item?.locator?.blockId).filter(Boolean);
|
||||
assert.equal(new Set(blockIds).size, blockIds.length, `搜索结果仍有同段落重复: ${JSON.stringify(blockIds)}`);
|
||||
return results.slice(0, TOP_N);
|
||||
|
||||
Reference in New Issue
Block a user