chore: checkpoint pi lab rust integration work
This commit is contained in:
@@ -16,7 +16,7 @@ const WORKSPACE_ID = process.env.MNOTE_E2E_WORKSPACE_ID || "local-ws:mnote-e2e:m
|
||||
const ROOT_PATH = process.env.MNOTE_E2E_ROOT_PATH || "/mnt/Data1T/Mnote_data/users/mnote-e2e/workspaces/my-space";
|
||||
const ROOT_URI = process.env.MNOTE_E2E_ROOT_URI || `file://${ROOT_PATH}`;
|
||||
const MODEL_PROVIDER = process.env.MNOTE_PI_REAL_MODEL_PROVIDER || "omniroute";
|
||||
const MODEL_ID = process.env.MNOTE_PI_REAL_MODEL_ID || "freefirst";
|
||||
const MODEL_ID = process.env.MNOTE_PI_REAL_MODEL_ID || "gpt-5.4-mini";
|
||||
const MARKER = `PI_REAL_LIGHTRAG_CARBOXY_OK_${STAMP}`;
|
||||
const CHROMIUM_EXECUTABLE = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE
|
||||
|| (fs.existsSync("/usr/bin/chromium-browser") ? "/usr/bin/chromium-browser" : "")
|
||||
@@ -185,15 +185,60 @@ async function expandToolTimelines(page) {
|
||||
}
|
||||
|
||||
function readSessionJsonl(sessionDir) {
|
||||
const files = fs.readdirSync(sessionDir)
|
||||
.filter((name) => name.endsWith(".jsonl"))
|
||||
.map((name) => path.join(sessionDir, name))
|
||||
.sort();
|
||||
const files = [];
|
||||
const walk = (dir) => {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) walk(full);
|
||||
else if (entry.isFile() && entry.name.endsWith(".jsonl")) files.push(full);
|
||||
}
|
||||
};
|
||||
walk(sessionDir);
|
||||
files.sort();
|
||||
const sessionFile = files[files.length - 1];
|
||||
assert(sessionFile, `session jsonl not found in ${sessionDir}`);
|
||||
return { sessionFile, raw: fs.readFileSync(sessionFile, "utf8") };
|
||||
}
|
||||
|
||||
function sessionHasKnowledgeRagEvidence(raw) {
|
||||
return String(raw || "")
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.some((line) => {
|
||||
try {
|
||||
const entry = JSON.parse(line);
|
||||
const message = entry && entry.message;
|
||||
if (
|
||||
!message
|
||||
|| message.role !== "toolResult"
|
||||
|| !/mnote_knowledge_rag_query|mnote\.knowledge_rag\.query/.test(String(message.toolName || ""))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const result = message.details && message.details.result;
|
||||
return Boolean(
|
||||
result
|
||||
&& ((Array.isArray(result.references) && result.references.length)
|
||||
|| (Array.isArray(result.citations) && result.citations.length)
|
||||
|| (Array.isArray(result.uiCitations) && result.uiCitations.length)),
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForSessionKnowledgeRagEvidence(sessionDir, timeoutMs = 10000) {
|
||||
const started = Date.now();
|
||||
let snapshot = readSessionJsonl(sessionDir);
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
if (sessionHasKnowledgeRagEvidence(snapshot.raw)) return snapshot;
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
snapshot = readSessionJsonl(sessionDir);
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
function extractAssistantText(text) {
|
||||
return text
|
||||
.replace(/\s+/g, " ")
|
||||
@@ -273,6 +318,8 @@ async function main() {
|
||||
.last();
|
||||
await markerLocator.waitFor({ state: "visible", timeout: TIMEOUT });
|
||||
await expandToolTimelines(page);
|
||||
const citationLocator = page.locator("[data-page-ai-pi-lab-citation]").first();
|
||||
await citationLocator.waitFor({ state: "visible", timeout: 10000 }).catch(() => null);
|
||||
const toolTimeline = page.locator("[data-page-ai-pi-lab-tool-timeline], [data-page-ai-pi-tool-timeline]").first();
|
||||
await toolTimeline.scrollIntoViewIfNeeded({ timeout: TIMEOUT }).catch(() => null);
|
||||
await page.screenshot({ path: path.join(OUT, "02-real-pi-lightrag-tool-card.png"), fullPage: false });
|
||||
@@ -284,17 +331,19 @@ async function main() {
|
||||
const assistantText = extractAssistantText((await markerLocator.textContent({ timeout: TIMEOUT })) || "");
|
||||
result.answerText = assistantText;
|
||||
const toolText = (await page.locator("[data-page-ai-pi-lab-tool-timeline], [data-page-ai-pi-tool-timeline]").allTextContents()).join("\n");
|
||||
const sessionJsonl = readSessionJsonl(session.piSessionDir);
|
||||
const sessionJsonl = await waitForSessionKnowledgeRagEvidence(session.piSessionDir);
|
||||
result.session.sessionFile = sessionJsonl.sessionFile;
|
||||
result.checks.toolCardVisible = /LightRAG|knowledge_rag|mnote_knowledge_rag_query|mnote\.knowledge_rag\.query/i.test(toolText);
|
||||
result.checks.queryToolCalled = /mnote_knowledge_rag_query|mnote\.knowledge_rag\.query/.test(sessionJsonl.raw);
|
||||
result.checks.referencesReturned = /references|citations|citationMarkdown|displayQuote/.test(sessionJsonl.raw);
|
||||
result.checks.referencesReturned = sessionHasKnowledgeRagEvidence(sessionJsonl.raw);
|
||||
result.checks.citationChipsVisible = await page.locator("[data-page-ai-pi-lab-citation]").count() > 0;
|
||||
result.checks.answerHasFiveItems = (assistantText.match(/(^|\s)([1-5]([.、.]|️⃣)|[-*]\s)/g) || []).length >= 5 || /5\s*种|五种|5\s*種|五種/.test(assistantText);
|
||||
result.checks.answerMentionsEvidence = /(\[[0-9]{3,4}\]|苯甲酰溴甲酯|碳酸二|硫酸二甲酯|磷酸三甲酯|引用|原文)/.test(assistantText);
|
||||
result.checks.noReasoningLeakInToolTimeline = !/reasoning_content|\"thinking\"/i.test(toolText);
|
||||
assert(result.checks.toolCardVisible, "UI 未显示 LightRAG/MNote RAG 工具卡");
|
||||
assert(result.checks.queryToolCalled, "Pi session JSONL 未记录 LightRAG 查询工具调用");
|
||||
assert(result.checks.referencesReturned, "Pi session JSONL 未包含 LightRAG references/citations");
|
||||
assert(result.checks.citationChipsVisible, "Pi 最终回答未显示可点击的 LightRAG 引用");
|
||||
assert(result.checks.answerHasFiveItems, "Pi 最终回答未明显列出 5 项");
|
||||
assert(result.checks.answerMentionsEvidence, "Pi 最终回答未明显包含引用依据");
|
||||
assert(result.checks.noReasoningLeakInToolTimeline, "工具时间线不应泄漏 thinking/reasoning 字段");
|
||||
|
||||
Reference in New Issue
Block a user