feat: port quality, escalation, KB version, site-map KB, experiments and metrics

This commit is contained in:
wangliang
2026-10-23 11:41:09 +08:00
parent 81b49c9350
commit b778570045
33 changed files with 2446 additions and 344 deletions
+26
View File
@@ -0,0 +1,26 @@
'use strict';
// 信息型页面 LLM 提炼成 FAQ(旧 bridge faq/llmRefiner.js 的移植)。
function createFaqRefiner(llm) {
const SYSTEM = `You turn website page content into a clean FAQ knowledge base entry.
Rules: output 3-8 "### Q: ..." / answer pairs based ONLY on the page content; never invent facts, numbers, or policies; answers 1-4 sentences; English; output only the FAQ body, no code fences.`;
async function refineToFaq(rawMarkdown, category) {
const text = String(rawMarkdown || '').slice(0, 6000);
if (!text.trim()) return null;
const res = await llm.chat({
messages: [
{ role: 'system', content: SYSTEM },
{ role: 'user', content: `Page category: ${category || 'general'}\n\nRaw page content:\n${text}` },
],
temperature: 0.2,
maxTokens: 800,
});
const faq = String(res.content || '').trim();
return faq.includes('### Q:') ? faq : null;
}
return { refineToFaq };
}
module.exports = { createFaqRefiner };