-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Observability AI Assistant] Screen Context #175885
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
Changes from all commits
ca57268
d05bfce
9862d17
3018007
d14a1ab
e4d60dd
f4a1fb9
37defe5
e5c77c8
5631579
998bfa4
28269fe
f0fad69
91d4c25
88c94a9
96b9a4e
7fade90
4c932c6
cd540f6
3bbe608
23457ab
2177d37
67e1f75
1ee69c5
d87b4f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import { | |
| import { RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public'; | ||
| import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; | ||
|
|
||
| import dedent from 'dedent'; | ||
| import { useKibana } from '../../utils/kibana_react'; | ||
| import { useFetchRule } from '../../hooks/use_fetch_rule'; | ||
| import { usePluginContext } from '../../hooks/use_plugin_context'; | ||
|
|
@@ -56,6 +57,9 @@ export function AlertDetails() { | |
| }, | ||
| http, | ||
| triggersActionsUi: { ruleTypeRegistry }, | ||
| observabilityAIAssistant: { | ||
| service: { setScreenContext }, | ||
| }, | ||
| uiSettings, | ||
| } = useKibana().services; | ||
|
|
||
|
|
@@ -71,6 +75,39 @@ export function AlertDetails() { | |
| const [summaryFields, setSummaryFields] = useState<AlertSummaryField[]>(); | ||
| const [alertStatus, setAlertStatus] = useState<AlertStatus>(); | ||
|
|
||
| useEffect(() => { | ||
| if (!alertDetail) { | ||
| return; | ||
| } | ||
|
|
||
| const screenDescription = dedent(`The user is looking at an ${ | ||
| alertDetail.formatted.active ? 'active' : 'recovered' | ||
| } alert. | ||
| It started at ${new Date( | ||
| alertDetail.formatted.start | ||
| ).toISOString()}, and was last updated at ${new Date( | ||
| alertDetail.formatted.lastUpdated | ||
| ).toISOString()}. | ||
|
|
||
| ${ | ||
| alertDetail.formatted.reason | ||
| ? `The reason given for the alert is ${alertDetail.formatted.reason}.` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i18n?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, everything we sent to the LLM needs to be in English. |
||
| : '' | ||
| } | ||
| `); | ||
|
|
||
| return setScreenContext({ | ||
| screenDescription, | ||
| data: [ | ||
| { | ||
| name: 'alert_fields', | ||
| description: 'The fields and values for the alert', | ||
| value: alertDetail.formatted.fields, | ||
| }, | ||
| ], | ||
| }); | ||
| }, [setScreenContext, alertDetail]); | ||
|
|
||
| useEffect(() => { | ||
| if (alertDetail) { | ||
| setRuleTypeModel(ruleTypeRegistry.get(alertDetail?.formatted.fields[ALERT_RULE_TYPE_ID]!)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { useParams } from 'react-router-dom'; | ||
| import { useIsMutating } from '@tanstack/react-query'; | ||
| import { EuiLoadingSpinner } from '@elastic/eui'; | ||
|
|
@@ -15,6 +15,7 @@ import type { ChromeBreadcrumb } from '@kbn/core-chrome-browser'; | |
| import type { SLOWithSummaryResponse } from '@kbn/slo-schema'; | ||
| import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; | ||
|
|
||
| import dedent from 'dedent'; | ||
| import { useKibana } from '../../utils/kibana_react'; | ||
| import { usePluginContext } from '../../hooks/use_plugin_context'; | ||
| import { useFetchSloDetails } from '../../hooks/slo/use_fetch_slo_details'; | ||
|
|
@@ -34,6 +35,9 @@ export function SloDetailsPage() { | |
| const { | ||
| application: { navigateToUrl }, | ||
| http: { basePath }, | ||
| observabilityAIAssistant: { | ||
| service: { setScreenContext }, | ||
| }, | ||
| } = useKibana().services; | ||
| const { ObservabilityPageTemplate } = usePluginContext(); | ||
|
|
||
|
|
@@ -53,6 +57,31 @@ export function SloDetailsPage() { | |
|
|
||
| useBreadcrumbs(getBreadcrumbs(basePath, slo)); | ||
|
|
||
| useEffect(() => { | ||
| if (!slo) { | ||
| return; | ||
| } | ||
|
|
||
| return setScreenContext({ | ||
| screenDescription: dedent(` | ||
| The user is looking at the detail page for the following SLO | ||
|
|
||
| Name: ${slo.name}. | ||
| Id: ${slo.id} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess we also need to slo.instanceId if it's not equal to *
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's available in the metadata below
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What metadata are you referring to?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if using the actual doc fields
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re: your second question: yes, that's useful to the LLM, but also available in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dominiqueclarke sorry I spoke to soon, I have not actually verified whether field names are available in the metadata. Where are the field names used (outside of SOs)? |
||
| Description: ${slo.description} | ||
| Observed value: ${slo.summary.sliValue} | ||
| Status: ${slo.summary.status} | ||
| `), | ||
| data: [ | ||
| { | ||
| name: 'slo', | ||
| description: 'The SLO and its metadata', | ||
| value: slo, | ||
| }, | ||
| ], | ||
| }); | ||
| }, [setScreenContext, slo]); | ||
|
|
||
| const isSloNotFound = !isLoading && slo === undefined; | ||
| if (isSloNotFound) { | ||
| return <PageNotFound />; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahzad31 We always use English when communicating with the LLM (think of this as an API call where you wouldn't translate the params either)