-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Security Assistant] Fixes relationship between sy…
…stem prompts & conversations (#161039) ## Summary This PR handles bugs - elastic/security-team#6977 - elastic/security-team#6978 - elastic/security-team#6979. Currently, below operations between System Prompts and Conversarions do not work. 1. When a prompt is set as default for all conversation, it should be automatically selected for any new conversation user creates. 2. When a new prompt is creates and set as default for all conversation, it should be automatically selected for any new conversation user creates. 3. When a prompt is edited such that, it is default for only certain conversation, it should be automatically selected for that conversation. 4. When a prompt is edited such that conversations are removed to have that default prompt, it should be automatically removed from conversation default system prompt list. In addition to above scenarios, this PR also handles one more bug. Consider below interface of Conversation which has a property `apiConfig.defaultSystemPrompt` is of type Prompt. It has been changed from `defaultSystemPrompt?: Prompt` to `defaultSystemPrompt?: string` where it will store `promptId` instead of complete prompt. The current model was posing a problem where, if a prompt was updated, all its copies in `Conversation` were needed to be updated leading to inconsistencies. This is now resolved. ```typescript export interface Conversation { apiConfig: { connectorId?: string; defaultSystemPrompt?: Prompt; provider?: OpenAiProviderType; }; id: string; messages: Message[]; replacements?: Record<string, string>; theme?: ConversationTheme; isDefault?: boolean; } ```
- Loading branch information
Showing
13 changed files
with
500 additions
and
58 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
x-pack/packages/kbn-elastic-assistant/impl/assistant/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const TEST_IDS = { | ||
SYSTEM_PROMPT_SELECTOR: 'systemPromptSelector', | ||
CONVERSATIONS_MULTISELECTOR: 'conversationMultiSelector', | ||
ADD_SYSTEM_PROMPT: 'addSystemPrompt', | ||
PROMPT_SUPERSELECT: 'promptSuperSelect', | ||
CONVERSATIONS_MULTISELECTOR_OPTION: (id: string) => `conversationMultiSelectorOption-${id}`, | ||
SYSTEM_PROMPT_MODAL: { | ||
ID: 'systemPromptModal', | ||
PROMPT_TEXT: 'systemPromptModalPromptText', | ||
TOGGLE_ALL_DEFAULT_CONVERSATIONS: 'systemPromptModalToggleDefaultConversations', | ||
SAVE: 'systemPromptModalSave', | ||
CANCEL: 'systemPromptModalCancel', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.