-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Observability AI Assistant] Create first Starter prompts #178907
Changes from 14 commits
675ac0f
482d705
a3d91ee
7567cf7
aa8a7ed
7f0fcdc
7643392
492707a
3afa675
6b4ea31
a6d081a
cdd6175
3ac8172
819ff0c
9a60c35
37e89df
e9a102b
d2200a8
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-templat | |
import React, { useContext, useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { KibanaEnvironmentContext } from '../../../context/kibana_environment_context/kibana_environment_context'; | ||
import { getPathForFeedback } from '../../../utils/get_path_for_feedback'; | ||
import { EnvironmentsContextProvider } from '../../../context/environments_context/environments_context'; | ||
|
@@ -118,21 +119,52 @@ export function ApmMainTemplate({ | |
isServerless: config?.serverlessOnboarding, | ||
}); | ||
|
||
let screenDescription = ''; | ||
|
||
if (!hasApmData && !hasApmIntegrations) { | ||
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. Made this change as the LLM was giving a suboptimal answer previously. When 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. good one, saw this as well |
||
screenDescription = | ||
'The user does not have the APM integration installed and does not have APM data.'; | ||
} else { | ||
screenDescription = hasApmData | ||
? 'The user has APM data.' | ||
: 'The user does not have APM data.'; | ||
screenDescription = hasApmIntegrations | ||
? `${screenDescription} The user has the APM integration installed.` | ||
: `${screenDescription} The user does not have the APM integration installed.`; | ||
} | ||
|
||
if (noDataConfig !== undefined) { | ||
screenDescription = `${screenDescription} The user is looking at a screen that tells them they do not have any data.`; | ||
} | ||
|
||
useEffect(() => { | ||
return aiAssistant?.service.setScreenContext({ | ||
screenDescription: [ | ||
hasApmData | ||
? 'The user has APM data.' | ||
: 'The user does not have APM data.', | ||
hasApmIntegrations | ||
? 'The user has the APM integration installed. ' | ||
: 'The user does not have the APM integration installed', | ||
noDataConfig !== undefined | ||
? 'The user is looking at a screen that tells them they do not have any data.' | ||
: '', | ||
].join('\n'), | ||
screenDescription, | ||
starterPrompts: [ | ||
...(!hasApmData | ||
CoenWarmer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
? [ | ||
{ | ||
title: i18n.translate( | ||
'xpack.apm.aiAssistant.starterPrompts.explainNoData.title', | ||
{ defaultMessage: 'Explain' } | ||
), | ||
prompt: i18n.translate( | ||
'xpack.apm.aiAssistant.starterPrompts.explainNoData.prompt', | ||
{ defaultMessage: "Why don't I see any data?" } | ||
), | ||
icon: 'sparkles', | ||
}, | ||
] | ||
: []), | ||
], | ||
}); | ||
}, [hasApmData, hasApmIntegrations, noDataConfig, aiAssistant]); | ||
}, [ | ||
hasApmData, | ||
hasApmIntegrations, | ||
noDataConfig, | ||
aiAssistant, | ||
screenDescription, | ||
]); | ||
|
||
const rightSideItems = [ | ||
...(showServiceGroupSaveButton ? [<ServiceGroupSaveButton />] : []), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 { useLoadRuleTypesQuery } from '@kbn/triggers-actions-ui-plugin/public'; | ||
import { useMemo } from 'react'; | ||
import { useKibana } from '../utils/kibana_react'; | ||
import { useGetFilteredRuleTypes } from './use_get_filtered_rule_types'; | ||
|
||
export function useGetAvailableRulesWithDescriptions() { | ||
const filteredRuleTypes = useGetFilteredRuleTypes(); | ||
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.
|
||
|
||
const { | ||
triggersActionsUi: { ruleTypeRegistry }, | ||
} = useKibana().services; | ||
|
||
const { | ||
ruleTypesState: { data: ruleTypes }, | ||
} = useLoadRuleTypesQuery({ | ||
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.
|
||
filteredRuleTypes, | ||
}); | ||
|
||
return useMemo(() => { | ||
const ruleTypesFromRuleTypeRegistry = ruleTypeRegistry.list(); | ||
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.
|
||
|
||
return Array.from(ruleTypes).map(([id, rule]) => { | ||
return { | ||
id, | ||
name: rule.name, | ||
description: ruleTypesFromRuleTypeRegistry.find((f) => f.id === id)?.description || '', | ||
}; | ||
}); | ||
}, [ruleTypeRegistry, ruleTypes]); | ||
} |
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.
Could we move the AI assistant code to its own file?
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.
Same comments for the other files. I think we could clean up the components.
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.
Not really. This functionality is intended for other plugins to give contextual information to the assistant about what the user is looking at right now.
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.
I think what @cauemarcondes means is that it could be a separate hook or something similar. I've also done that in other places in APM (e.g.
getThroughputScreenContext
).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.
I saw those and didn't think it was super readable. But if its important for you, I will oblige
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.
IMO it keeps the component clean and small making it easy to maintain.
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.
IMO jumping between files hinders readability and leads engineers to just leave it alone because they don't see the contents anymore. Many, many examples of this in the Kibana codebase abound.
As stated though I will update.
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.
I tend to agree and disagree with that 😄. The screen context/description is very specific for the AI assistant to know about this page/component. Me as a developer who is actively working on these components/pages I don't care what the assistant is doing. I know they are there though. What I want is to see a clean component, not having a bunch of static text on my way 😆.
For you, I think it'll be even easier as you'll have a clean file with only AI stuff.