Smarter chatbot + support matching by meaning (Marty 2026-11-16): the hub's semantic match (free core2 embeddings)
Chatbot (chatbot.js + netkb.js route): a hand-off pattern still answers first; then the hub's POST /v1/kb/match answers with this site's entry when it is sure, keeps or overrules the CANNED regex hit, and picks the AI prompt context, this site's own entries first. 1.5 s timeout, then the hub is skipped for 30 s and the old pattern + BM25 path answers (NETKB_MATCH=0 = off). Support desk: while a signed-in member types a new ticket, POST /api/my/support/suggest shows the closest help answers (KB entries only, incl. ones written from past tickets, never another member's ticket; BM25 when the hub is down); Send is never blocked. help-screen.js?v=20261116sg. Tests: qa/netkb-semantic.test.mjs (route/suggest decisions, fail soft, shared-file parity; run.sh kb) and qa/support-suggest.mjs (run.sh member). netkb.js is the same file in all eight network sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,9 @@
|
||||
+ '<label>What is it about?<select class="field" id="hnCat">' + CATS.map(c => '<option>' + esc(c) + '</option>').join('') + '</select></label>'
|
||||
+ '<label>Subject<input class="field" id="hnSubject" maxlength="140" placeholder="A few words, like: my spin link stopped rotating"></label>'
|
||||
+ '<label>Message<textarea class="field" id="hnBody" rows="6" maxlength="5000" placeholder="What happened, what you expected, and anything you already tried. Never send your recovery phrase or private key."></textarea></label>'
|
||||
+ '<div id="hnSuggest" class="hsg" hidden aria-live="polite"></div>'
|
||||
+ '<div class="acts"><button class="btn pri" type="button" id="hnSend">Send to support</button><button class="btn" type="button" id="hnCancel">Cancel</button><span class="hmsg" id="hnMsg"></span></div></div>';
|
||||
suggest();
|
||||
$('hnCancel').addEventListener('click', () => { box.hidden = true; box.innerHTML = ''; });
|
||||
const send = $('hnSend');
|
||||
send.addEventListener('click', async () => {
|
||||
@@ -50,6 +52,27 @@
|
||||
});
|
||||
$('hnSubject').focus();
|
||||
}
|
||||
// help answers while typing (2026-11-16): debounced, from the KB only (the hub's semantic match); a suggestion never blocks Send
|
||||
function suggest() {
|
||||
const box = $('hnSuggest'), subj = $('hnSubject'), body = $('hnBody');
|
||||
if (!box || !subj || !body) return;
|
||||
let timer = null, seq = 0, last = '';
|
||||
const run = async () => {
|
||||
const text = (subj.value + ' ' + body.value).replace(/\s+/g, ' ').trim();
|
||||
if (text.replace(/[^A-Za-z0-9]/g, '').length < 10) { box.hidden = true; box.innerHTML = ''; last = ''; return; }
|
||||
if (text === last) return; last = text; const mine = ++seq;
|
||||
let r; try { r = await CR.api('/api/my/support/suggest', { subject: subj.value, body: body.value }); } catch (e) { return; }
|
||||
if (mine !== seq || !document.body.contains(box)) return;
|
||||
const items = (r && r.items) || [];
|
||||
if (!items.length) { box.hidden = true; box.innerHTML = ''; return; }
|
||||
box.innerHTML = '<p class="hsg-h"><b>These answers may help</b> <span>You can still send your ticket.</span></p>'
|
||||
+ items.map(i => '<details><summary>' + esc(i.title) + (i.site ? ' <span class="hsg-s">(' + esc(i.site) + ')</span>' : '') + (i.fromTicket ? ' <span class="hsg-s">from a past ticket</span>' : '') + '</summary>'
|
||||
+ '<div class="hsg-b">' + linkify(i.answer) + (i.link && i.site ? '<br><a href="' + esc(i.link) + '" target="_blank" rel="noopener">Open ' + esc(i.site) + '</a>' : '') + '</div></details>').join('');
|
||||
box.hidden = false;
|
||||
};
|
||||
const kick = () => { clearTimeout(timer); timer = setTimeout(run, 700); };
|
||||
subj.addEventListener('input', kick); body.addEventListener('input', kick);
|
||||
}
|
||||
async function open(ref) {
|
||||
host().innerHTML = '<div class="panel"><span class="muted">loading</span></div>';
|
||||
let v; try { v = await CR.get('/api/my/support/' + encodeURIComponent(ref)); }
|
||||
|
||||
Reference in New Issue
Block a user