-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[AI assistant] Add setting to configure default LLM #231940
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d076ad1
Add setting to configure default LLM
KDKHD 779ffdc
Add tests
KDKHD 208f283
lint
KDKHD 3563bde
lint
KDKHD 48a2772
lint
KDKHD 041d4cf
lint
KDKHD 6ac17a7
lint
KDKHD b4a1986
lint
KDKHD 3517b93
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 3b01e0b
lint
KDKHD 9a3379c
Merge branch 'main' into feature/default-llm-setting
elasticmachine a791032
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine f284831
roles
KDKHD 8a78db9
types
KDKHD d5b18c3
[CI] Auto-commit changed files from 'node scripts/telemetry_check'
kibanamachine 08af810
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine 9abe55c
code review
KDKHD 514f167
Merge branch 'main' of github.com:elastic/kibana into feature/default…
KDKHD 1505aa5
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine 0d01972
cr
KDKHD 8735c66
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine 98dd5ef
@rbrtj code review
KDKHD f7a1838
Merge branch 'main' into feature/default-llm-setting
elasticmachine 334e6ac
style
KDKHD 8c20a40
Merge branch 'feature/default-llm-setting' of github.com:KDKHD/kibana…
KDKHD 2463262
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine 62b3851
typo
KDKHD aaa797b
fix test
KDKHD 131f051
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine c2091b7
Merge branch 'main' into feature/default-llm-setting
KDKHD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
8 changes: 8 additions & 0 deletions
8
x-pack/platform/plugins/private/gen_ai_settings/common/constants.ts
This file contains hidden or 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,8 @@ | ||
| /* | ||
| * 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 NO_DEFAULT_CONNECTOR = 'NO_DEFAULT_CONNECTOR'; |
52 changes: 52 additions & 0 deletions
52
.../private/gen_ai_settings/public/components/bottom_bar_actions/bottom_bar_actions.test.tsx
This file contains hidden or 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,52 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import { render, screen } from '@testing-library/react'; | ||
| import { BottomBarActions } from './bottom_bar_actions'; | ||
| import React from 'react'; | ||
| import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; | ||
|
|
||
| describe('bottom_bar_actions', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| function Providers({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <IntlProvider locale="en" messages={{}}> | ||
| {children} | ||
| </IntlProvider> | ||
| ); | ||
| } | ||
|
|
||
| it('renders correctly', () => { | ||
| const onDiscardChanges = jest.fn(); | ||
| const onSave = jest.fn(); | ||
| render( | ||
| <BottomBarActions | ||
| isLoading={true} | ||
| onDiscardChanges={onDiscardChanges} | ||
| onSave={onSave} | ||
| unsavedChangesCount={5} | ||
| saveLabel="Save Changes" | ||
| appTestSubj="genAiSettings" | ||
| />, | ||
| { wrapper: Providers } | ||
| ); | ||
|
|
||
| expect(screen.getByTestId('genAiSettingsBottomBar')).toBeInTheDocument(); | ||
| expect(screen.getByText('5 unsaved changes')).toBeInTheDocument(); | ||
| expect(screen.getByText('Save Changes')).toBeInTheDocument(); | ||
| expect(screen.getByText('Discard changes')).toBeInTheDocument(); | ||
|
|
||
| expect(onDiscardChanges).not.toHaveBeenCalled(); | ||
| screen.getByText('Discard changes').click(); | ||
| expect(onDiscardChanges).toHaveBeenCalled(); | ||
|
|
||
| expect(onSave).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
103 changes: 103 additions & 0 deletions
103
...ugins/private/gen_ai_settings/public/components/bottom_bar_actions/bottom_bar_actions.tsx
This file contains hidden or 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,103 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| import { | ||
| EuiBottomBar, | ||
| EuiButton, | ||
| EuiButtonEmpty, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiHealth, | ||
| EuiText, | ||
| EuiToolTip, | ||
| } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import React from 'react'; | ||
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
|
||
| interface Props { | ||
| unsavedChangesCount: number; | ||
| isLoading: boolean; | ||
| onDiscardChanges: () => void; | ||
| onSave: () => void; | ||
| saveLabel: string; | ||
| appTestSubj: string; | ||
| areChangesInvalid?: boolean; | ||
| } | ||
|
|
||
| export const BottomBarActions = ({ | ||
| isLoading, | ||
| onDiscardChanges, | ||
| onSave, | ||
| unsavedChangesCount, | ||
| saveLabel, | ||
| appTestSubj, | ||
| areChangesInvalid = false, | ||
| }: Props) => { | ||
| return ( | ||
| <EuiBottomBar paddingSize="s" data-test-subj={`${appTestSubj}BottomBar`}> | ||
| <EuiFlexGroup justifyContent="spaceBetween" alignItems="center"> | ||
| <EuiFlexItem | ||
| grow={false} | ||
| css={{ | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| }} | ||
| > | ||
| <EuiHealth color="warning" /> | ||
| <EuiText> | ||
| <FormattedMessage | ||
| id="xpack.gen_ai_settings.bottomBarActions.unsavedChanges" | ||
| defaultMessage="{unsavedChangesCount, plural, =0{0 unsaved changes} one {1 unsaved change} other {# unsaved changes}}" | ||
| values={{ unsavedChangesCount }} | ||
| /> | ||
| </EuiText> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiFlexGroup justifyContent="flexEnd"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiButtonEmpty | ||
| data-test-subj={`${appTestSubj}BottomBarActionsDiscardChangesButton`} | ||
| color="text" | ||
| onClick={onDiscardChanges} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.gen_ai_settings.bottomBarActions.discardChangesButtonAriaLabel" | ||
| defaultMessage="Discard changes" | ||
| /> | ||
| </EuiButtonEmpty> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiToolTip | ||
| content={ | ||
| areChangesInvalid && | ||
| i18n.translate( | ||
| 'xpack.gen_ai_settings.bottomBarActions.saveButtonTooltipWithInvalidChanges', | ||
| { | ||
| defaultMessage: 'Fix invalid settings before saving.', | ||
| } | ||
| ) | ||
| } | ||
| > | ||
| <EuiButton | ||
| disabled={areChangesInvalid} | ||
| data-test-subj={`${appTestSubj}BottomBarActionsButton`} | ||
| onClick={onSave} | ||
| fill | ||
| isLoading={isLoading} | ||
| color="success" | ||
| iconType="check" | ||
| > | ||
| {saveLabel} | ||
| </EuiButton> | ||
| </EuiToolTip> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiBottomBar> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.