Skip to content

Commit ff3822d

Browse files
authored
[Obs AI Assistant] Fix re-deploy model timeout and status polling (#220445)
Closes elastic/obs-ai-assistant-team#247 Closes #217912 ## Summary ### Problems - The `/warmup_model` endpoint doesn't return immediately and waits for the KB to be ready. If there is no ML nodes or sufficient capacity in the ML node, the API can timeout. - Since the endpoint doesn't return immediately, we don't poll for status continuously. - Knowledge base tab doesn't show `Inspect` if no ML nodes are available. ### Solutions - Show `Inspect` information in the knowledge base - Return `/warmup_model` immediately (we don't need to wait for the model to be ready since we are polling), and start polling - If the user refreshes the browser and if the `kbState` is in `DEPLOYING_MODEL` keep polling for status ### Checklist - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
1 parent c046881 commit ff3822d

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

x-pack/platform/packages/shared/kbn-ai-assistant/src/hooks/use_knowledge_base.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export function useKnowledgeBase(): UseKnowledgeBaseResult {
4141

4242
// poll for status when installing, until install is complete and the KB is ready
4343
const isPolling =
44-
(isInstalling || isWarmingUpModel) && statusRequest.value?.kbState !== KnowledgeBaseState.READY;
44+
((isInstalling || isWarmingUpModel) &&
45+
statusRequest.value?.kbState !== KnowledgeBaseState.READY) ||
46+
statusRequest.value?.kbState === KnowledgeBaseState.DEPLOYING_MODEL;
4547

4648
useEffect(() => {
4749
// toggle installing state to false once KB is ready

x-pack/platform/plugins/private/observability_ai_assistant_management/public/routes/components/knowledge_base_tab.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
import { useKnowledgeBase } from '@kbn/ai-assistant/src/hooks';
3939
import { KnowledgeBaseInstallationStatusPanel } from '@kbn/ai-assistant/src/knowledge_base/knowledge_base_installation_status_panel';
4040
import { SettingUpKnowledgeBase } from '@kbn/ai-assistant/src/knowledge_base/setting_up_knowledge_base';
41+
import { InspectKnowledgeBasePopover } from '@kbn/ai-assistant/src/knowledge_base/inspect_knowlegde_base_popover';
4142
import { useGetKnowledgeBaseEntries } from '../../hooks/use_get_knowledge_base_entries';
4243
import { categorizeEntries, KnowledgeBaseEntryCategory } from '../../helpers/categorize_entries';
4344
import { KnowledgeBaseEditManualEntryFlyout } from './knowledge_base_edit_manual_entry_flyout';
@@ -241,7 +242,7 @@ export function KnowledgeBaseTab() {
241242
setQuery(e?.currentTarget.value || '');
242243
};
243244

244-
if (knowledgeBase.status.loading && !knowledgeBase.isInstalling) {
245+
if (knowledgeBase.status.loading && !knowledgeBase.isPolling) {
245246
return (
246247
<EuiFlexGroup alignItems="center" direction="column">
247248
<EuiFlexItem grow>
@@ -450,7 +451,10 @@ export function KnowledgeBaseTab() {
450451
<EuiPanel hasBorder paddingSize="xl" grow={false} className={panelClassname}>
451452
<EuiFlexItem grow className={centerMaxWidthClassName}>
452453
{knowledgeBase.isInstalling ? (
453-
<SettingUpKnowledgeBase />
454+
<>
455+
<SettingUpKnowledgeBase />
456+
<InspectKnowledgeBasePopover knowledgeBase={knowledgeBase} />
457+
</>
454458
) : (
455459
<KnowledgeBaseInstallationStatusPanel knowledgeBase={knowledgeBase} />
456460
)}

x-pack/platform/plugins/shared/observability_ai_assistant/server/service/client/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,13 +732,11 @@ export class ObservabilityAIAssistantClient {
732732
};
733733

734734
warmupKbModel = (inferenceId: string) => {
735-
return waitForKbModel({
736-
core: this.dependencies.core,
737-
esClient: this.dependencies.esClient,
738-
logger: this.dependencies.logger,
739-
config: this.dependencies.config,
740-
inferenceId,
741-
});
735+
const { esClient, logger } = this.dependencies;
736+
737+
logger.debug(`Warming up model for for inference ID: ${inferenceId}`);
738+
warmupModel({ esClient, logger, inferenceId }).catch(() => {});
739+
return;
742740
};
743741

744742
reIndexKnowledgeBaseWithLock = () => {

0 commit comments

Comments
 (0)