-
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.
[AI Assistant] Add setting for preferred type (#179233)
Adds a setting in the `aiAssistantManagementSelection` plugin that allows users to set the preferred Assistant type. The allowed values are: - `default`: the status quo, which is: show the Observability AI Assistant in Observability apps, the Security AI Assistant in Security solution apps, and none in the other apps. - `never`: Never show any AI Assistant. - `observability`: Show the Observability AI Assistant everywhere, except for Security solution apps. - `security`: ~Show the Security AI Assistant everywhere, except for Observability apps.~ it is up to the solutions to respect the setting. See [x-pack/plugins/observability_solution/observability_ai_assistant_app/public/hooks/is_nav_control_visible.tsx](https://github.com/elastic/kibana/pull/179233/files#diff-753a9aae298da45c5bd96bc2cacaa437ac53e165069ad6323973dd3c2879d4ae) for an example. It should also be set in the specific Serverless config: [config/serverless.oblt.yml](https://github.com/elastic/kibana/pull/179233/files#diff-358680d2b72268283dca4f3efb976cd924b7b5bce822e07c8871d061b4bb339e). Update: this is now labeled as an Observability-only setting. ![CleanShot 2024-04-05 at 09 28 32@2x](https://github.com/elastic/kibana/assets/352732/fa6edeea-eaca-4ec3-86ec-f00effa95f93) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
826f7cb
commit 52c65b7
Showing
22 changed files
with
308 additions
and
41 deletions.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
src/plugins/ai_assistant_management/selection/common/ai_assistant_type.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,13 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export enum AIAssistantType { | ||
Observability = 'observability', | ||
Default = 'default', | ||
Never = 'never', | ||
} |
9 changes: 9 additions & 0 deletions
9
src/plugins/ai_assistant_management/selection/common/ui_setting_keys.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,9 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const PREFERRED_AI_ASSISTANT_TYPE_SETTING_KEY = 'aiAssistant:preferredAIAssistantType'; |
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
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
13 changes: 13 additions & 0 deletions
13
src/plugins/ai_assistant_management/selection/public/types.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,13 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { AIAssistantType } from '../common/ai_assistant_type'; | ||
|
||
export interface ConfigSchema { | ||
preferredAIAssistantType: AIAssistantType; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/plugins/ai_assistant_management/selection/server/config.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,32 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { schema, TypeOf } from '@kbn/config-schema'; | ||
import { PluginConfigDescriptor } from '@kbn/core-plugins-server'; | ||
import { AIAssistantType } from '../common/ai_assistant_type'; | ||
|
||
const configSchema = schema.object({ | ||
enabled: schema.boolean({ defaultValue: true }), | ||
preferredAIAssistantType: schema.oneOf( | ||
[ | ||
schema.literal(AIAssistantType.Default), | ||
schema.literal(AIAssistantType.Never), | ||
schema.literal(AIAssistantType.Observability), | ||
], | ||
{ defaultValue: AIAssistantType.Default } | ||
), | ||
}); | ||
|
||
export type AIAssistantManagementSelectionConfig = TypeOf<typeof configSchema>; | ||
|
||
export const config: PluginConfigDescriptor<AIAssistantManagementSelectionConfig> = { | ||
schema: configSchema, | ||
exposeToBrowser: { | ||
preferredAIAssistantType: true, | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/plugins/ai_assistant_management/selection/server/index.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,16 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { PluginInitializerContext } from '@kbn/core/server'; | ||
|
||
export { config } from './config'; | ||
|
||
export const plugin = async (initContext: PluginInitializerContext) => { | ||
const { AIAssistantManagementSelectionPlugin } = await import('./plugin'); | ||
return new AIAssistantManagementSelectionPlugin(initContext); | ||
}; |
90 changes: 90 additions & 0 deletions
90
src/plugins/ai_assistant_management/selection/server/plugin.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,90 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { | ||
PluginInitializerContext, | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
DEFAULT_APP_CATEGORIES, | ||
} from '@kbn/core/server'; | ||
import { schema } from '@kbn/config-schema'; | ||
import type { AIAssistantManagementSelectionConfig } from './config'; | ||
import type { | ||
AIAssistantManagementSelectionPluginServerSetup, | ||
AIAssistantManagementSelectionPluginServerStart, | ||
} from './types'; | ||
import { AIAssistantType } from '../common/ai_assistant_type'; | ||
import { PREFERRED_AI_ASSISTANT_TYPE_SETTING_KEY } from '../common/ui_setting_keys'; | ||
|
||
export class AIAssistantManagementSelectionPlugin | ||
implements | ||
Plugin< | ||
AIAssistantManagementSelectionPluginServerSetup, | ||
AIAssistantManagementSelectionPluginServerStart | ||
> | ||
{ | ||
private readonly config: AIAssistantManagementSelectionConfig; | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.config = initializerContext.config.get(); | ||
} | ||
|
||
public setup(core: CoreSetup) { | ||
core.uiSettings.register({ | ||
[PREFERRED_AI_ASSISTANT_TYPE_SETTING_KEY]: { | ||
name: i18n.translate('aiAssistantManagementSelection.preferredAIAssistantTypeSettingName', { | ||
defaultMessage: 'Observability AI Assistant scope', | ||
}), | ||
category: [DEFAULT_APP_CATEGORIES.observability.id], | ||
value: this.config.preferredAIAssistantType, | ||
description: i18n.translate( | ||
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingDescription', | ||
{ | ||
defaultMessage: | ||
'<em>[technical preview]</em> Whether to show the Observability AI Assistant menu item in Observability, everywhere, or nowhere.', | ||
} | ||
), | ||
schema: schema.oneOf( | ||
[ | ||
schema.literal(AIAssistantType.Default), | ||
schema.literal(AIAssistantType.Observability), | ||
schema.literal(AIAssistantType.Never), | ||
], | ||
{ defaultValue: this.config.preferredAIAssistantType } | ||
), | ||
options: [AIAssistantType.Default, AIAssistantType.Observability, AIAssistantType.Never], | ||
type: 'select', | ||
optionLabels: { | ||
[AIAssistantType.Default]: i18n.translate( | ||
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingValueDefault', | ||
{ defaultMessage: 'Observability only (default)' } | ||
), | ||
[AIAssistantType.Observability]: i18n.translate( | ||
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingValueObservability', | ||
{ defaultMessage: 'Everywhere' } | ||
), | ||
[AIAssistantType.Never]: i18n.translate( | ||
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingValueNever', | ||
{ defaultMessage: 'Nowhere' } | ||
), | ||
}, | ||
requiresPageReload: true, | ||
}, | ||
}); | ||
|
||
return {}; | ||
} | ||
|
||
public start(core: CoreStart) { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/plugins/ai_assistant_management/selection/server/types.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,18 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface AIAssistantManagementSelectionPluginServerDependenciesStart {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface AIAssistantManagementSelectionPluginServerDependenciesSetup {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface AIAssistantManagementSelectionPluginServerStart {} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface AIAssistantManagementSelectionPluginServerSetup {} |
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
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.