Skip to content

Commit

Permalink
Extract AI assistant to package (#194552)
Browse files Browse the repository at this point in the history
## Summary

This extracts the Observability AI Assistant into a shared package so
Search and Observability can both consume it.

A few notes:

This still relies on significantly tight coupling with the Obs AI
assistant plugin, which we will want to slowly decouple over time. It
means that currently to consume this in multiple places, you need to
provide a number of plugins for useKibana. Hopefully we can get rid of
that and replace them with props eventually and make the interface a
little less plugin-dependent.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
sphilipse and kibanamachine authored Oct 10, 2024
1 parent e6c2750 commit 8a3a059
Show file tree
Hide file tree
Showing 130 changed files with 1,414 additions and 978 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ x-pack/plugins/actions @elastic/response-ops
x-pack/test/alerting_api_integration/common/plugins/actions_simulators @elastic/response-ops
packages/kbn-actions-types @elastic/response-ops
src/plugins/advanced_settings @elastic/appex-sharedux @elastic/kibana-management
x-pack/packages/kbn-ai-assistant @elastic/search-kibana
src/plugins/ai_assistant_management/selection @elastic/obs-knowledge-team
x-pack/packages/ml/aiops_change_point_detection @elastic/ml-ui
x-pack/packages/ml/aiops_common @elastic/ml-ui
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"@kbn/actions-simulators-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/actions_simulators",
"@kbn/actions-types": "link:packages/kbn-actions-types",
"@kbn/advanced-settings-plugin": "link:src/plugins/advanced_settings",
"@kbn/ai-assistant": "link:x-pack/packages/kbn-ai-assistant",
"@kbn/ai-assistant-management-plugin": "link:src/plugins/ai_assistant_management/selection",
"@kbn/aiops-change-point-detection": "link:x-pack/packages/ml/aiops_change_point_detection",
"@kbn/aiops-common": "link:x-pack/packages/ml/aiops_common",
Expand Down
2 changes: 2 additions & 0 deletions test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
// 'xpack.reporting.poll.jobsRefresh.intervalErrorMultiplier (number)',
'xpack.rollup.ui.enabled (boolean?)',
'xpack.saved_object_tagging.cache_refresh_interval (duration?)',

'xpack.searchAssistant.ui.enabled (boolean?)',
'xpack.searchInferenceEndpoints.ui.enabled (boolean?)',
'xpack.searchPlayground.ui.enabled (boolean?)',
'xpack.security.loginAssistanceMessage (string?)',
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"@kbn/actions-types/*": ["packages/kbn-actions-types/*"],
"@kbn/advanced-settings-plugin": ["src/plugins/advanced_settings"],
"@kbn/advanced-settings-plugin/*": ["src/plugins/advanced_settings/*"],
"@kbn/ai-assistant": ["x-pack/packages/kbn-ai-assistant"],
"@kbn/ai-assistant/*": ["x-pack/packages/kbn-ai-assistant/*"],
"@kbn/ai-assistant-management-plugin": ["src/plugins/ai_assistant_management/selection"],
"@kbn/ai-assistant-management-plugin/*": ["src/plugins/ai_assistant_management/selection/*"],
"@kbn/aiops-change-point-detection": ["x-pack/packages/ml/aiops_change_point_detection"],
Expand Down
63 changes: 48 additions & 15 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"packages/ml/aiops_log_rate_analysis",
"plugins/aiops"
],
"xpack.aiAssistant": "packages/kbn-ai-assistant",
"xpack.alerting": "plugins/alerting",
"xpack.eventLog": "plugins/event_log",
"xpack.stackAlerts": "plugins/stack_alerts",
Expand Down Expand Up @@ -44,9 +45,15 @@
"xpack.dataVisualizer": "plugins/data_visualizer",
"xpack.exploratoryView": "plugins/observability_solution/exploratory_view",
"xpack.fileUpload": "plugins/file_upload",
"xpack.globalSearch": ["plugins/global_search"],
"xpack.globalSearchBar": ["plugins/global_search_bar"],
"xpack.graph": ["plugins/graph"],
"xpack.globalSearch": [
"plugins/global_search"
],
"xpack.globalSearchBar": [
"plugins/global_search_bar"
],
"xpack.graph": [
"plugins/graph"
],
"xpack.grokDebugger": "plugins/grokdebugger",
"xpack.idxMgmt": "plugins/index_management",
"xpack.idxMgmtPackage": "packages/index-management",
Expand All @@ -68,9 +75,13 @@
"xpack.licenseMgmt": "plugins/license_management",
"xpack.licensing": "plugins/licensing",
"xpack.lists": "plugins/lists",
"xpack.logstash": ["plugins/logstash"],
"xpack.logstash": [
"plugins/logstash"
],
"xpack.main": "legacy/plugins/xpack_main",
"xpack.maps": ["plugins/maps"],
"xpack.maps": [
"plugins/maps"
],
"xpack.metricsData": "plugins/observability_solution/metrics_data_access",
"xpack.ml": [
"packages/ml/anomaly_utils",
Expand All @@ -85,7 +96,9 @@
"packages/ml/ui_actions",
"plugins/ml"
],
"xpack.monitoring": ["plugins/monitoring"],
"xpack.monitoring": [
"plugins/monitoring"
],
"xpack.observability": "plugins/observability_solution/observability",
"xpack.observabilityAiAssistant": [
"plugins/observability_solution/observability_ai_assistant",
Expand All @@ -100,10 +113,17 @@
],
"xpack.osquery": ["plugins/osquery"],
"xpack.painlessLab": "plugins/painless_lab",
"xpack.profiling": ["plugins/observability_solution/profiling"],
"xpack.profiling": [
"plugins/observability_solution/profiling"
],
"xpack.remoteClusters": "plugins/remote_clusters",
"xpack.reporting": ["plugins/reporting"],
"xpack.rollupJobs": ["packages/rollup", "plugins/rollup"],
"xpack.reporting": [
"plugins/reporting"
],
"xpack.rollupJobs": [
"packages/rollup",
"plugins/rollup"
],
"xpack.runtimeFields": "plugins/runtime_fields",
"xpack.screenshotting": "plugins/screenshotting",
"xpack.searchSharedUI": "packages/search/shared_ui",
Expand All @@ -114,7 +134,10 @@
"xpack.searchInferenceEndpoints": "plugins/search_inference_endpoints",
"xpack.searchAssistant": "plugins/search_assistant",
"xpack.searchProfiler": "plugins/searchprofiler",
"xpack.security": ["plugins/security", "packages/security"],
"xpack.security": [
"plugins/security",
"packages/security"
],
"xpack.server": "legacy/server",
"xpack.serverless": "plugins/serverless",
"xpack.serverlessSearch": "plugins/serverless_search",
Expand All @@ -126,20 +149,30 @@
"xpack.slo": "plugins/observability_solution/slo",
"xpack.snapshotRestore": "plugins/snapshot_restore",
"xpack.spaces": "plugins/spaces",
"xpack.savedObjectsTagging": ["plugins/saved_objects_tagging"],
"xpack.savedObjectsTagging": [
"plugins/saved_objects_tagging"
],
"xpack.taskManager": "legacy/plugins/task_manager",
"xpack.threatIntelligence": "plugins/threat_intelligence",
"xpack.timelines": "plugins/timelines",
"xpack.transform": "plugins/transform",
"xpack.triggersActionsUI": "plugins/triggers_actions_ui",
"xpack.upgradeAssistant": "plugins/upgrade_assistant",
"xpack.uptime": ["plugins/observability_solution/uptime"],
"xpack.synthetics": ["plugins/observability_solution/synthetics"],
"xpack.ux": ["plugins/observability_solution/ux"],
"xpack.uptime": [
"plugins/observability_solution/uptime"
],
"xpack.synthetics": [
"plugins/observability_solution/synthetics"
],
"xpack.ux": [
"plugins/observability_solution/ux"
],
"xpack.urlDrilldown": "plugins/drilldowns/url_drilldown",
"xpack.watcher": "plugins/watcher"
},
"exclude": ["examples"],
"exclude": [
"examples"
],
"translations": [
"@kbn/translations-plugin/translations/zh-CN.json",
"@kbn/translations-plugin/translations/ja-JP.json",
Expand Down
3 changes: 3 additions & 0 deletions x-pack/packages/kbn-ai-assistant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/ai-assistant

Provides components, types and context to render the AI Assistant in plugins.
7 changes: 7 additions & 0 deletions x-pack/packages/kbn-ai-assistant/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* 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 * from './src';
18 changes: 18 additions & 0 deletions x-pack/packages/kbn-ai-assistant/jest.config.js
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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/packages/kbn_ai_assistant_src',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/packages/kbn-ai-assistant/src/**/*.{ts,tsx}',
'!<rootDir>/x-pack/packages/kbn-ai-assistant/src/*.test.{ts,tsx}',
],
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/packages/kbn-ai-assistant'],
};
5 changes: 5 additions & 0 deletions x-pack/packages/kbn-ai-assistant/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "@kbn/ai-assistant",
"owner": "@elastic/search-kibana",
"type": "shared-browser"
}
7 changes: 7 additions & 0 deletions x-pack/packages/kbn-ai-assistant/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/ai-assistant",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0",
"sideEffects": false
}
9 changes: 9 additions & 0 deletions x-pack/packages/kbn-ai-assistant/setup_tests.ts
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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import '@testing-library/jest-dom';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ export function AskAssistantButton({
variant,
onClick,
}: AskAssistantButtonProps) {
const buttonLabel = i18n.translate(
'xpack.observabilityAiAssistant.askAssistantButton.buttonLabel',
{
defaultMessage: 'Ask Assistant',
}
);
const buttonLabel = i18n.translate('xpack.aiAssistant.askAssistantButton.buttonLabel', {
defaultMessage: 'Ask Assistant',
});

const aiAssistantLabel = i18n.translate('xpack.aiAssistant.aiAssistantLabel', {
defaultMessage: 'AI Assistant',
});

switch (variant) {
case 'basic':
Expand Down Expand Up @@ -84,23 +85,13 @@ export function AskAssistantButton({
return (
<EuiToolTip
position="top"
title={i18n.translate('xpack.observabilityAiAssistant.askAssistantButton.popoverTitle', {
defaultMessage: 'AI Assistant for Observability',
title={aiAssistantLabel}
content={i18n.translate('xpack.aiAssistant.askAssistantButton.popoverContent', {
defaultMessage: 'Get insights into your data with the Elastic Assistant',
})}
content={i18n.translate(
'xpack.observabilityAiAssistant.askAssistantButton.popoverContent',
{
defaultMessage: 'Get insights into your data with the Elastic Assistant',
}
)}
>
<EuiButtonIcon
aria-label={i18n.translate(
'xpack.observabilityAiAssistant.askAssistantButton.popoverTitle',
{
defaultMessage: 'AI Assistant for Observability',
}
)}
aria-label={aiAssistantLabel}
data-test-subj="observabilityAiAssistantAskAssistantButtonButtonIcon"
display={fill ? 'fill' : 'base'}
iconType="sparkles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function HideExpandConversationListButton(props: HideExpandConversationLi
{...props}
>
{props.isExpanded
? i18n.translate('xpack.observabilityAiAssistant.hideExpandConversationButton.hide', {
? i18n.translate('xpack.aiAssistant.hideExpandConversationButton.hide', {
defaultMessage: 'Hide chats',
})
: i18n.translate('xpack.observabilityAiAssistant.hideExpandConversationButton.show', {
: i18n.translate('xpack.aiAssistant.hideExpandConversationButton.show', {
defaultMessage: 'Show chats',
})}
</EuiButtonEmpty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function NewChatButton(
iconType="newChat"
{...nextProps}
>
{i18n.translate('xpack.observabilityAiAssistant.newChatButton', {
{i18n.translate('xpack.aiAssistant.newChatButton', {
defaultMessage: 'New chat',
})}
</EuiButton>
Expand Down
Loading

0 comments on commit 8a3a059

Please sign in to comment.