Site assistant: a question that names another network site skips this site's instant answers (a hand-off still wins), so 'how much is a Boost on ViralAdBlitz' asked on another site gets that site's answer from the shared knowledge base. chatbot.test covers it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 12:49:25 -06:00
parent d6e36a65bc
commit ae7077da57
3 changed files with 29 additions and 4 deletions
+9 -2
View File
@@ -116,8 +116,15 @@ async function answer(message, historyText) {
async function answerRaw(message, historyText) {
const msg = String(message || '').trim().slice(0, 600);
if (!msg) return { error: 'Say something first.' };
let hit = null, kbOk = true;
try { hit = await kb.fastPath(msg); } catch (e) { kbOk = false; console.error('kb fast path', e.message); }
let hit = null, kbOk = true, other = [];
try {
await kb.load();
// a question about another network site (named, and this site not named) skips this site's instant answers, except a hand-off
other = kb.namesOther(msg, S.hubSite);
if (other.length && new RegExp('\\b' + S.name.replace(/[^A-Za-z0-9]+/g, '\\s*') + '\\b', 'i').test(msg)) other = [];
hit = await kb.fastPath(msg);
if (hit && other.length && !hit.handoff) hit = null;
} catch (e) { kbOk = false; console.error('kb fast path', e.message); }
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});
if (!kbOk) for (const c of S.canned) if (c.re && c.re.test(msg)) return Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
let kbBlock = '', kbIds = [], hits = [];