]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
webui : fix handling incomplete chunks (#16107)
authorQuentin Bramas <redacted>
Mon, 22 Sep 2025 08:53:13 +0000 (10:53 +0200)
committerGitHub <redacted>
Mon, 22 Sep 2025 08:53:13 +0000 (11:53 +0300)
tools/server/webui/src/lib/services/chat.ts

index 7133bbab814a5ee7eaaeeaacf3c62d194ddc74a5..91573a86640781012f630c2a07ded5c74ddd2f70 100644 (file)
@@ -264,12 +264,14 @@ export class ChatService {
                let lastTimings: ChatMessageTimings | undefined;
 
                try {
+                       let chunk = '';
                        while (true) {
                                const { done, value } = await reader.read();
                                if (done) break;
 
-                               const chunk = decoder.decode(value, { stream: true });
+                               chunk += decoder.decode(value, { stream: true });
                                const lines = chunk.split('\n');
+                               chunk = lines.pop() || ''; // Save incomplete line for next read
 
                                for (const line of lines) {
                                        if (line.startsWith('data: ')) {