-
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
[Obs AI Assistant] fix knowledge base installation state #206130
Merged
neptunian
merged 12 commits into
elastic:main
from
neptunian:205970-fix-kb-install-status
Jan 15, 2025
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
77362bf
fix install status
neptunian 0e5d496
update state
neptunian bd26ec6
unit tests
neptunian 5faea80
fix translation
neptunian 656f7cf
Merge branch 'main' into 205970-fix-kb-install-status
neptunian b23e701
Merge branch 'main' into 205970-fix-kb-install-status
neptunian f9482f5
remove connector length check, update tests, change model in progress…
neptunian 8e8f101
move connector check to parent
neptunian ea007ca
Update x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/welc…
neptunian 1ac26c6
Update x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/welc…
neptunian 846ce1c
Update x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/welc…
neptunian cc14aae
Update x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/welc…
neptunian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,21 @@ export function WelcomeMessageKnowledgeBase({ | |
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
const handleClosePopover = () => setIsPopoverOpen(false); | ||
|
||
const [checkForInstallStatus, setCheckForInstallStatus] = useState(false); | ||
const [pollKnowledgeBaseStatus, setPollKnowledgeBaseStatus] = useState(false); | ||
|
||
// When the knowledge base is installed, show a success message for 3 seconds | ||
// installing state when the inference endpoint is being created and the model is being deployed | ||
const isInstalling = | ||
knowledgeBase.isInstalling || | ||
(knowledgeBase.status.value?.endpoint && knowledgeBase.status.value?.ready === false); | ||
|
||
// start polling kb status if inference endpoint is being created or has been created but model isn't ready | ||
useEffect(() => { | ||
if (isInstalling) { | ||
setPollKnowledgeBaseStatus(true); | ||
} | ||
}, [isInstalling]); | ||
|
||
// When the knowledge base is installed and ready, show a success message for 3 seconds | ||
useEffect(() => { | ||
if (previouslyNotInstalled && knowledgeBase.status.value?.ready) { | ||
setTimeoutTime(3000); | ||
|
@@ -51,33 +63,30 @@ export function WelcomeMessageKnowledgeBase({ | |
} | ||
}, [knowledgeBase.status.value?.ready, previouslyNotInstalled, reset]); | ||
|
||
// When the knowledge base is installed, stop checking for install status | ||
// When the knowledge base is ready, stop polling for status | ||
useEffect(() => { | ||
if (!checkForInstallStatus && knowledgeBase.status.value?.ready) { | ||
setCheckForInstallStatus(false); | ||
if (knowledgeBase.status.value?.ready) { | ||
setPollKnowledgeBaseStatus(false); | ||
} | ||
}, [checkForInstallStatus, knowledgeBase.status.value?.ready]); | ||
}, [pollKnowledgeBaseStatus, knowledgeBase.status.value?.ready]); | ||
|
||
// Check for install status every 5 seconds | ||
// poll for knowledge base status every 5 seconds | ||
useInterval( | ||
() => { | ||
knowledgeBase.status.refresh(); | ||
}, | ||
checkForInstallStatus ? 5000 : null | ||
pollKnowledgeBaseStatus ? 5000 : null | ||
); | ||
|
||
const handleRetryInstall = async () => { | ||
setCheckForInstallStatus(true); | ||
// gets called if there was an error previously during install or user has a preconfigured connector | ||
// and is first time installing | ||
const handleInstall = async () => { | ||
setIsPopoverOpen(false); | ||
|
||
await knowledgeBase.install().then(() => { | ||
setCheckForInstallStatus(false); | ||
}); | ||
await knowledgeBase.install(); | ||
}; | ||
|
||
return knowledgeBase.status.value?.ready !== undefined ? ( | ||
<> | ||
{knowledgeBase.isInstalling ? ( | ||
{isInstalling ? ( | ||
<> | ||
<EuiText color="subdued" size="s"> | ||
{i18n.translate('xpack.aiAssistant.welcomeMessage.weAreSettingUpTextLabel', { | ||
|
@@ -100,69 +109,70 @@ export function WelcomeMessageKnowledgeBase({ | |
</> | ||
) : null} | ||
|
||
{connectors.connectors?.length ? ( | ||
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. moved check to parent. what case would we want to mount this component before setting up a connector? can't think of one. |
||
(!knowledgeBase.isInstalling && knowledgeBase.installError) || | ||
(!knowledgeBase.isInstalling && | ||
knowledgeBase.status.loading === false && | ||
knowledgeBase.status.value.ready === false) ? ( | ||
<> | ||
<EuiText color="subdued" size="s"> | ||
{i18n.translate( | ||
'xpack.aiAssistant.welcomeMessageKnowledgeBase.yourKnowledgeBaseIsNotSetUpCorrectlyLabel', | ||
{ defaultMessage: `Your Knowledge base hasn't been set up.` } | ||
)} | ||
</EuiText> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiFlexGroup justifyContent="center"> | ||
<EuiFlexItem grow={false}> | ||
<div> | ||
<EuiButton | ||
color="primary" | ||
data-test-subj="observabilityAiAssistantWelcomeMessageSetUpKnowledgeBaseButton" | ||
fill | ||
isLoading={checkForInstallStatus} | ||
iconType="importAction" | ||
onClick={handleRetryInstall} | ||
> | ||
{i18n.translate('xpack.aiAssistant.welcomeMessage.retryButtonLabel', { | ||
defaultMessage: 'Install Knowledge base', | ||
})} | ||
</EuiButton> | ||
</div> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem grow={false}> | ||
<EuiPopover | ||
button={ | ||
<EuiButtonEmpty | ||
data-test-subj="observabilityAiAssistantWelcomeMessageInspectErrorsButton" | ||
iconType="inspect" | ||
onClick={() => setIsPopoverOpen(!isPopoverOpen)} | ||
{ | ||
// already has a connector and kb is not installing | ||
// and has an install error (timeout, etc) or inference endpoint has not been created | ||
neptunian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
connectors.connectors?.length && !isInstalling ? ( | ||
knowledgeBase.installError || !knowledgeBase.status.value.endpoint ? ( | ||
<> | ||
<EuiText color="subdued" size="s"> | ||
{i18n.translate( | ||
'xpack.aiAssistant.welcomeMessageKnowledgeBase.yourKnowledgeBaseIsNotSetUpCorrectlyLabel', | ||
{ defaultMessage: `Your Knowledge base hasn't been set up.` } | ||
)} | ||
</EuiText> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<EuiFlexGroup justifyContent="center"> | ||
<EuiFlexItem grow={false}> | ||
<div> | ||
<EuiButton | ||
color="primary" | ||
data-test-subj="observabilityAiAssistantWelcomeMessageSetUpKnowledgeBaseButton" | ||
fill | ||
isLoading={false} | ||
iconType="importAction" | ||
onClick={handleInstall} | ||
> | ||
{i18n.translate( | ||
'xpack.aiAssistant.welcomeMessage.inspectErrorsButtonEmptyLabel', | ||
{ defaultMessage: 'Inspect issues' } | ||
)} | ||
</EuiButtonEmpty> | ||
} | ||
isOpen={isPopoverOpen} | ||
panelPaddingSize="none" | ||
closePopover={handleClosePopover} | ||
> | ||
<WelcomeMessageKnowledgeBaseSetupErrorPanel | ||
knowledgeBase={knowledgeBase} | ||
onRetryInstall={handleRetryInstall} | ||
/> | ||
</EuiPopover> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer size="m" /> | ||
</> | ||
{i18n.translate('xpack.aiAssistant.welcomeMessage.retryButtonLabel', { | ||
defaultMessage: 'Install Knowledge base', | ||
})} | ||
</EuiButton> | ||
</div> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem grow={false}> | ||
<EuiPopover | ||
button={ | ||
<EuiButtonEmpty | ||
data-test-subj="observabilityAiAssistantWelcomeMessageInspectErrorsButton" | ||
iconType="inspect" | ||
onClick={() => setIsPopoverOpen(!isPopoverOpen)} | ||
> | ||
{i18n.translate( | ||
'xpack.aiAssistant.welcomeMessage.inspectErrorsButtonEmptyLabel', | ||
{ defaultMessage: 'Inspect issues' } | ||
)} | ||
</EuiButtonEmpty> | ||
} | ||
isOpen={isPopoverOpen} | ||
panelPaddingSize="none" | ||
closePopover={handleClosePopover} | ||
> | ||
<WelcomeMessageKnowledgeBaseSetupErrorPanel | ||
knowledgeBase={knowledgeBase} | ||
onRetryInstall={handleInstall} | ||
/> | ||
</EuiPopover> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiSpacer size="m" /> | ||
</> | ||
) : null | ||
) : null | ||
) : null} | ||
} | ||
|
||
{showHasBeenInstalled ? ( | ||
<div> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
don't stop checking kb status after
/setup
has returned. model may not be ready.