Skip to content

Commit

Permalink
[Obs AI Assistant] Export context_instruction const from a common pac…
Browse files Browse the repository at this point in the history
…kage (elastic#206673)
  • Loading branch information
viduni94 committed Jan 15, 2025
1 parent 979ab73 commit a44fc6a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
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.
*/

export const CONTEXT_INSTRUCTION =
'The following contextual information is available to help you understand the alert';
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ export { concatenateChatCompletionChunks } from './utils/concatenate_chat_comple
export { ShortIdTable } from './utils/short_id_table';

export { KnowledgeBaseType } from './types';

export { CONTEXT_INSTRUCTION } from './context_instruction';
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"optionalPlugins": ["cloud", "serverless"],
"requiredBundles": ["kibanaReact", "kibanaUtils"],
"runtimePluginDependencies": ["ml"],
"extraPublicDirs": []
"extraPublicDirs": ["common"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import useObservable from 'react-use/lib/useObservable';
import dedent from 'dedent';
import { ILicense } from '@kbn/licensing-plugin/public';
import { CONTEXT_INSTRUCTION } from '../../../common/context_instruction';
import { MessageRole, type Message } from '../../../common/types';
import { ObservabilityAIAssistantChatServiceContext } from '../../context/observability_ai_assistant_chat_service_context';
import { useAbortableAsync } from '../../hooks/use_abortable_async';
Expand All @@ -43,10 +44,6 @@ import { InsightBase } from './insight_base';
import { ActionsMenu } from './actions_menu';
import { ObservabilityAIAssistantTelemetryEventType } from '../../analytics/telemetry_event_type';

// defined and used in x-pack/solutions/observability/plugins/observability/public/pages/alert_details/alert_details_contextual_insights.tsx
const CONTEXT_INSTRUCTION =
'The following contextual information is available to help you understand the alert';

function getLastMessageOfType(messages: Message[], role: MessageRole) {
return last(messages.filter((msg) => msg.message.role === role));
}
Expand Down
18 changes: 6 additions & 12 deletions x-pack/solutions/observability/plugins/observability/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"type": "plugin",
"id": "@kbn/observability-plugin",
"owner": [
"@elastic/obs-ux-management-team"
],
"owner": ["@elastic/obs-ux-management-team"],
"group": "observability",
"visibility": "private",
"plugin": {
"id": "observability",
"browser": true,
"server": true,
"configPath": [
"xpack",
"observability"
],
"configPath": ["xpack", "observability"],
"requiredPlugins": [
"aiops",
"alerting",
Expand Down Expand Up @@ -45,7 +40,8 @@
"logsExplorer",
"logsShared",
"licensing",
"navigation"
"navigation",
"observabilityAIAssistant"
],
"optionalPlugins": [
"discover",
Expand All @@ -68,8 +64,6 @@
"stackAlerts",
"spaces"
],
"extraPublicDirs": [
"common"
]
"extraPublicDirs": ["common"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import React, { useCallback } from 'react';
import { i18n } from '@kbn/i18n';
import { ALERT_RULE_PARAMETERS } from '@kbn/rule-data-utils';
import dedent from 'dedent';
import { CONTEXT_INSTRUCTION } from '@kbn/observability-ai-assistant-plugin/common';
import { type AlertDetailsContextualInsight } from '../../../server/services';
import { useKibana } from '../../utils/kibana_react';
import { AlertData } from '../../hooks/use_fetch_alert_detail';

// used in x-pack/platform/plugins/shared/observability_solution/observability_ai_assistant/public/components/insight/insight.tsx
const CONTEXT_INSTRUCTION =
'The following contextual information is available to help you understand the alert';

export function AlertDetailContextualInsights({ alert }: { alert: AlertData | null }) {
const {
services: { observabilityAIAssistant, http },
Expand Down

0 comments on commit a44fc6a

Please sign in to comment.