feat(r42): improve KB grounding accuracy and add clear-history
R42 was missing knowledge-graph information (e.g. pension questions) because retrieval and context-building dropped relevant facts: - retrieval: exact-token TF-IDF could not match Dutch compound words, so a "pensioen" query scored 0 against "pensioenregeling" / "partnerpensioen" and never retrieved them. Add a compound-word fallback (shared >=6-char stem or containment, 0.4x weight) alongside exact matching. - rag: deep article content was only injected for verbatim-mentioned topics; retrieved topics contributed just a 200-char description. Inject ~1000 chars of content for up to 5 topics (mentions first, then top-ranked retrieved) and widen the description snippet to 320. - prompts: add a NAUWKEURIGHEID block (use all relevant facts, call lookup_topic before giving up) and relax the 4-sentence cap for detail/list answers so complete facts aren't summarised away. Also add a clear-history control: a trash button in the chat header (confirm dialog) wipes chat🧵{userId} and reseeds the greeting via clearThread() in useChat. Tests: compound-word matching + rag deep-content injection. Spec updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,19 @@ export function useChat({ user, isAdmin }) {
|
||||
setMessages(prev => prev.map(m => (m.id === id ? { ...m, ...patch } : m)));
|
||||
}, []);
|
||||
|
||||
/** Wipe the persisted thread and reset to a fresh greeting. */
|
||||
const clearThread = useCallback(() => {
|
||||
seenDeltaKeys.current = new Set();
|
||||
const greeting = {
|
||||
id: `m_${Date.now()}`,
|
||||
role: 'assistant',
|
||||
content: STRINGS.greeting(user?.name || 'daar'),
|
||||
ts: Date.now(),
|
||||
};
|
||||
setMessages([greeting]);
|
||||
if (threadKey) storage.set(threadKey, [greeting]);
|
||||
}, [user, threadKey]);
|
||||
|
||||
const send = useCallback(async (text) => {
|
||||
const trimmed = (text || '').trim();
|
||||
if (!trimmed || !user) return;
|
||||
@@ -225,5 +238,6 @@ export function useChat({ user, isAdmin }) {
|
||||
errored,
|
||||
send,
|
||||
updateMessage,
|
||||
clearThread,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user