mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Security solution] Fix regenerate button with LangGraph (#188249)
This commit is contained in:
parent
c2997378d4
commit
f72a321a9c
1 changed files with 13 additions and 0 deletions
|
@ -49,6 +49,19 @@ export const persistConversationChanges = async ({
|
|||
});
|
||||
}
|
||||
|
||||
const lastMessage = state.conversation.messages
|
||||
? state.conversation.messages[state.conversation.messages.length - 1]
|
||||
: undefined;
|
||||
if (lastMessage && lastMessage.content === state.input && lastMessage.role === 'user') {
|
||||
// this is a regenerated message, do not update the conversation again
|
||||
const langChainMessages = getLangChainMessages(state.conversation.messages ?? []);
|
||||
const messages = langChainMessages.slice(0, -1); // all but the last message
|
||||
return {
|
||||
conversation: state.conversation,
|
||||
messages,
|
||||
};
|
||||
}
|
||||
|
||||
const updatedConversation = await conversationsDataClient?.appendConversationMessages({
|
||||
existingConversation: conversation ? conversation : state.conversation,
|
||||
messages: [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue