From fd93bd3414a1725219e14561bc5640b62f9fd4a1 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 14 Apr 2026 11:03:36 -0500 Subject: [PATCH] refac --- src/lib/components/notes/NoteEditor/Chat.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/notes/NoteEditor/Chat.svelte b/src/lib/components/notes/NoteEditor/Chat.svelte index 2430f602e1..f8e4b0c914 100644 --- a/src/lib/components/notes/NoteEditor/Chat.svelte +++ b/src/lib/components/notes/NoteEditor/Chat.svelte @@ -169,13 +169,20 @@ Based on the user's instruction, update and enhance the existing notes or select : '') + (selectedContent ? `\n${selectedContent?.text}` : ''); + // Filter out empty assistant placeholder messages to avoid sending + // an empty trailing assistant message as "response prefill", which is + // incompatible with enable_thinking in llama.cpp and similar backends. + const filteredMessages = messages.filter( + (m) => !(m.role === 'assistant' && m.content === '') + ); + const chatMessages = JSON.parse( JSON.stringify([ { role: 'system', content: `${system}` }, - ...messages + ...filteredMessages ]) );