mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.15`: - [[Security solution] Fix regenerate button with LangGraph (#188249)](https://github.com/elastic/kibana/pull/188249) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2024-07-13T14:16:12Z","message":"[Security solution] Fix regenerate button with LangGraph (#188249)","sha":"f72a321a9c80b8c9ccb30f30a5870200989e3ae1","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team: SecuritySolution","Team:Security Generative AI","v8.15.0","v8.16.0"],"title":"[Security solution] Fix regenerate button with LangGraph","number":188249,"url":"https://github.com/elastic/kibana/pull/188249","mergeCommit":{"message":"[Security solution] Fix regenerate button with LangGraph (#188249)","sha":"f72a321a9c80b8c9ccb30f30a5870200989e3ae1"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188249","number":188249,"mergeCommit":{"message":"[Security solution] Fix regenerate button with LangGraph (#188249)","sha":"f72a321a9c80b8c9ccb30f30a5870200989e3ae1"}}]}] BACKPORT--> Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
38677570cb
commit
8d6510f30e
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