-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Obs AI Assistant] knowledge base integration tests (#189000)
Closes #188999 - integration tests for knowledge base api - adds new config field `modelId`, for internal use, to override elser model id - refactors `knowledgeBaseService.setup()` to fix bug where if the model failed to install when calling ml.putTrainedModel, we dont get stuck polling and retrying the install. We were assuming that the first error that gets throw when the model is exists would only happen once and the return true or false and poll for whether its done installing. But the installation could fail itself causing getTrainedModelsStats to continuously throw and try to install the model. Now user immediately gets error if model fails to install and polling does not happen. --------- Co-authored-by: James Gowdy <[email protected]>
- Loading branch information
1 parent
d79bdfd
commit f18224c
Showing
10 changed files
with
470 additions
and
274 deletions.
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
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
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
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
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
31 changes: 31 additions & 0 deletions
31
x-pack/test/observability_ai_assistant_api_integration/tests/knowledge_base/helpers.ts
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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 { MachineLearningProvider } from '../../../api_integration/services/ml'; | ||
import { SUPPORTED_TRAINED_MODELS } from '../../../functional/services/ml/api'; | ||
|
||
export const TINY_ELSER = { | ||
...SUPPORTED_TRAINED_MODELS.TINY_ELSER, | ||
id: SUPPORTED_TRAINED_MODELS.TINY_ELSER.name, | ||
}; | ||
|
||
export async function createKnowledgeBaseModel(ml: ReturnType<typeof MachineLearningProvider>) { | ||
const config = { | ||
...ml.api.getTrainedModelConfig(TINY_ELSER.name), | ||
input: { | ||
field_names: ['text_field'], | ||
}, | ||
}; | ||
await ml.api.importTrainedModel(TINY_ELSER.name, TINY_ELSER.id, config); | ||
await ml.api.assureMlStatsIndexExists(); | ||
} | ||
export async function deleteKnowledgeBaseModel(ml: ReturnType<typeof MachineLearningProvider>) { | ||
await ml.api.stopTrainedModelDeploymentES(TINY_ELSER.id, true); | ||
await ml.api.deleteTrainedModelES(TINY_ELSER.id); | ||
await ml.api.cleanMlIndices(); | ||
await ml.testResources.cleanMLSavedObjects(); | ||
} |
Oops, something went wrong.