Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Adds support for custom Security Assistant SystemPrompts and Conversations #159365

Merged
merged 5 commits into from
Jun 13, 2023

Conversation

spong
Copy link
Member

@spong spong commented Jun 9, 2023

Summary

Adds the following new abilities to the Security Assistant:

  • Adds ability to create/delete custom SystemPrompts
    • Configurable Name, Prompt, Default Conversations, and Default for New Conversations
    • Introduces System Prompt setting within Conversation Settings
  • Adds ability to create/delete custom Conversations
    • Create conversation in-line within the Conversation selector by just typing the new conversation name and pressing enter
    • Applies configured SystemPrompt and default connector on conversation creation
  • Extracts baseSystemPrompts so they can be provided to the AssistantContextProvider on a per solution basis. The consolidates assistant dependency defaults to the x-pack/plugins/security_solution/public/assistant/content and x-pack/packages/kbn-elastic-assistant/impl/content directories respectively.
    • All Security SystemPrompts now organized in BASE_SECURITY_SYSTEM_PROMPTS
    • All Security Conversations organized in BASE_SECURITY_CONVERSATIONS

See epic https://github.com/elastic/security-team/issues/6775 (internal) for additional details.

Checklist

Delete any items that are not applicable to this PR.

@spong spong self-assigned this Jun 9, 2023
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 4104 4113 +9

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/elastic-assistant 55 63 +8

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 10.8MB 10.8MB -55.1KB
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 75 83 +8

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 410 414 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 491 495 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @spong

@spong spong added Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. release_note:feature Makes this part of the condensed release notes v8.9.0 Feature:Security Assistant Security Assistant needs_docs labels Jun 13, 2023
setTimeout(() => {
deleteConversation(cId);
}, 0);
// onSystemPromptDeleted(cId);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz delete 🙂

(newOptions: ConversationSelectorOption[]) => {
if (newOptions.length === 0) {
setSelectedOptions([]);
// handleSelectionChange([]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz delete 🙂

} else if (conversationOptions.findIndex((o) => o.label === newOptions?.[0].label) !== -1) {
setSelectedConversationId(newOptions?.[0].label);
}
// setSelectedConversationId(value ?? DEFAULT_CONVERSATION_TITLE);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz delete 🙂

/>
</EuiFormRow>

{provider === OpenAiProviderType.OpenAi && <></>}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or add back specific conversation/api settings

</EuiFlexItem>
<EuiFlexItem grow={false}>
{/* Right offset to compensate for 'selected' icon of EuiSuperSelect since native footers aren't supported*/}
<div style={{ width: '24px' }} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider creating a const for the style

export const ADD_SYSTEM_PROMPT = i18n.translate(
'xpack.elasticAssistant.assistant.promptEditor.systemPrompt.systemPromptModal.addSystemPromptTitle',
{
defaultMessage: 'Add system prompt...',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be caps since proper noun/feature

export const ADD_NEW_SYSTEM_PROMPT = i18n.translate(
'xpack.elasticAssistant.assistant.firstPromptEditor.addNewSystemPrompt',
{
defaultMessage: 'Add new system prompt...',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be caps b/c proper noun/feature

Comment on lines +203 to +204
allQuickPrompts: localStorageQuickPrompts ?? [],
allSystemPrompts: localStorageSystemPrompts ?? [],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify referential integrity WRT re-renders

@spong spong marked this pull request as ready for review June 13, 2023 18:03
@spong spong requested review from a team as code owners June 13, 2023 18:03
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Copy link
Contributor

@andrew-goldstein andrew-goldstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these features @spong! 🙏
Also thanks for paring on the review & desk testing
LGTM 🚀

@spong spong merged commit 6b65e90 into elastic:main Jun 13, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 13, 2023
@spong spong deleted the security-assistant-system-prompt-crud branch June 13, 2023 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Security Assistant Security Assistant needs_docs release_note:feature Makes this part of the condensed release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants