mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-28 08:31:25 +00:00
webui : Fix messages payload sent to chat completions (#16402)
* 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
This commit is contained in:
committed by
GitHub
parent
5113efd34c
commit
136bda78c5
Binary file not shown.
@@ -550,7 +550,6 @@ class ChatStore {
|
|||||||
await this.updateConversationName(this.activeConversation.id, title);
|
await this.updateConversationName(this.activeConversation.id, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
const allMessages = await DatabaseStore.getConversationMessages(this.activeConversation.id);
|
|
||||||
const assistantMessage = await this.createAssistantMessage(userMessage.id);
|
const assistantMessage = await this.createAssistantMessage(userMessage.id);
|
||||||
|
|
||||||
if (!assistantMessage) {
|
if (!assistantMessage) {
|
||||||
@@ -560,15 +559,23 @@ class ChatStore {
|
|||||||
this.activeMessages.push(assistantMessage);
|
this.activeMessages.push(assistantMessage);
|
||||||
// Don't update currNode until after streaming completes to maintain proper conversation path
|
// Don't update currNode until after streaming completes to maintain proper conversation path
|
||||||
|
|
||||||
await this.streamChatCompletion(allMessages, assistantMessage, undefined, (error: Error) => {
|
const conversationContext = this.activeMessages.slice(0, -1);
|
||||||
if (error.name === 'ContextError' && userMessage) {
|
|
||||||
const userMessageIndex = this.findMessageIndex(userMessage.id);
|
await this.streamChatCompletion(
|
||||||
if (userMessageIndex !== -1) {
|
conversationContext,
|
||||||
this.activeMessages.splice(userMessageIndex, 1);
|
assistantMessage,
|
||||||
DatabaseStore.deleteMessage(userMessage.id).catch(console.error);
|
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) {
|
} catch (error) {
|
||||||
if (this.isAbortError(error)) {
|
if (this.isAbortError(error)) {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
@@ -810,7 +817,6 @@ class ChatStore {
|
|||||||
this.currentResponse = '';
|
this.currentResponse = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const allMessages = await DatabaseStore.getConversationMessages(this.activeConversation.id);
|
|
||||||
const assistantMessage = await this.createAssistantMessage();
|
const assistantMessage = await this.createAssistantMessage();
|
||||||
|
|
||||||
if (!assistantMessage) {
|
if (!assistantMessage) {
|
||||||
@@ -821,7 +827,9 @@ class ChatStore {
|
|||||||
await DatabaseStore.updateCurrentNode(this.activeConversation.id, assistantMessage.id);
|
await DatabaseStore.updateCurrentNode(this.activeConversation.id, assistantMessage.id);
|
||||||
this.activeConversation.currNode = 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) {
|
} catch (regenerateError) {
|
||||||
console.error('Failed to regenerate response:', regenerateError);
|
console.error('Failed to regenerate response:', regenerateError);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user