fix knowledge rag docx sidecar locator

This commit is contained in:
lix-2026
2026-06-09 18:40:48 +08:00
parent 516121e6f9
commit 6ef233772e
6 changed files with 338 additions and 194 deletions
@@ -70,7 +70,7 @@ async function apiSearch(context) {
rootUri: ROOT_URI,
workspaceId: WORKSPACE_ID,
query: QUERY,
mode: "mix",
mode: "exact",
topK: 20,
chunkTopK: 20,
includeChunkContent: true,
@@ -178,6 +178,8 @@ async function clickAndAuditRow(page, index, apiResult) {
const evidenceText = locator?.openAction?.params?.evidenceText || apiResult?.locator?.openAction?.params?.evidenceText || apiResult?.quote || rowText;
const overlap = longestCommonSubstringLength(state.highlightedText, evidenceText);
const compactHighlighted = compactText(state.highlightedText);
const compactEvidence = compactText(evidenceText);
assert.equal(state.panelBlockId, locator.blockId, `${index + 1} 条 panel blockId 不一致: ${JSON.stringify(state, null, 2)}`);
assert(state.highlightedText.includes(QUERY), `${index + 1} 条定位高亮未包含 query: ${JSON.stringify(state, null, 2)}`);
assert(
@@ -185,11 +187,9 @@ async function clickAndAuditRow(page, index, apiResult) {
`${index + 1} 条仍是短词高亮,不是段落级高亮: ${JSON.stringify(state, null, 2)}`,
);
assert(
overlap >= 10 || (
state.highlightedTag === "P"
&& compactText(state.highlightedText).includes(compactText(QUERY))
&& compactText(state.highlightedText).length >= 6
),
overlap >= Math.min(10, Math.max(4, compactEvidence.length))
|| compactHighlighted.includes(compactEvidence)
|| compactEvidence.includes(compactHighlighted),
`${index + 1} 条搜索结果与实际定位上下文不一致: ${JSON.stringify({ rowText, evidenceText, overlap, state }, null, 2)}`,
);