]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
webui : Fix messages payload sent to chat completions (#16402)
authorAleksander Grygier <redacted>
Fri, 3 Oct 2025 07:11:34 +0000 (09:11 +0200)
committerGitHub <redacted>
Fri, 3 Oct 2025 07:11:34 +0000 (10:11 +0300)
* fix: Include just the currently active message branches instead of all in chat completions request

* chore: Build webui static output

* chore: Formatting

* chore: update webui build output

tools/server/public/index.html.gz
tools/server/webui/src/lib/stores/chat.svelte.ts

index 4f18a634ce5454acc56570aa0218cd703707bc10..4a9efbc2f5af3d9b8fa520cf8bce033951e0571e 100644 (file)
Binary files a/tools/server/public/index.html.gz and b/tools/server/public/index.html.gz differ
index 4a6d3a8c61f602b79c2c9468583f0278d842f911..5a24f3f356677becbffeda7c32adf5cb29e5d5e8 100644 (file)
@@ -550,7 +550,6 @@ class ChatStore {
                                await this.updateConversationName(this.activeConversation.id, title);
                        }
 
-                       const allMessages = await DatabaseStore.getConversationMessages(this.activeConversation.id);
                        const assistantMessage = await this.createAssistantMessage(userMessage.id);
 
                        if (!assistantMessage) {
@@ -560,15 +559,23 @@ class ChatStore {
                        this.activeMessages.push(assistantMessage);
                        // Don't update currNode until after streaming completes to maintain proper conversation path
 
-                       await this.streamChatCompletion(allMessages, assistantMessage, undefined, (error: Error) => {
-                               if (error.name === 'ContextError' && userMessage) {
-                                       const userMessageIndex = this.findMessageIndex(userMessage.id);
-                                       if (userMessageIndex !== -1) {
-                                               this.activeMessages.splice(userMessageIndex, 1);
-                                               DatabaseStore.deleteMessage(userMessage.id).catch(console.error);
+                       const conversationContext = this.activeMessages.slice(0, -1);
+
+                       await this.streamChatCompletion(
+                               conversationContext,
+                               assistantMessage,
+                               undefined,
+                               (error: Error) => {
+                                       if (error.name === 'ContextError' && userMessage) {
+                                               const userMessageIndex = this.findMessageIndex(userMessage.id);
+
+                                               if (userMessageIndex !== -1) {
+                                                       this.activeMessages.splice(userMessageIndex, 1);
+                                                       DatabaseStore.deleteMessage(userMessage.id).catch(console.error);
+                                               }
                                        }
                                }
-                       });
+                       );
                } catch (error) {
                        if (this.isAbortError(error)) {
                                this.isLoading = false;
@@ -810,7 +817,6 @@ class ChatStore {
                        this.currentResponse = '';
 
                        try {
-                               const allMessages = await DatabaseStore.getConversationMessages(this.activeConversation.id);
                                const assistantMessage = await this.createAssistantMessage();
 
                                if (!assistantMessage) {
@@ -821,7 +827,9 @@ class ChatStore {
                                await DatabaseStore.updateCurrentNode(this.activeConversation.id, assistantMessage.id);
                                this.activeConversation.currNode = assistantMessage.id;
 
-                               await this.streamChatCompletion(allMessages, assistantMessage);
+                               const conversationContext = this.activeMessages.slice(0, -1);
+
+                               await this.streamChatCompletion(conversationContext, assistantMessage);
                        } catch (regenerateError) {
                                console.error('Failed to regenerate response:', regenerateError);
                                this.isLoading = false;