Skip to content

Commit

Permalink
[8.11] [Obs AI Assistant] Use ELSER v2 (elastic#170092) (elastic#170173)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.11`:
- [[Obs AI Assistant] Use ELSER v2
(elastic#170092)](elastic#170092)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dario
Gieselaar","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-30T19:03:35Z","message":"[Obs
AI Assistant] Use ELSER v2 (elastic#170092)\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"beae7b1448d00f95c3e89ccd6f62c38d5a973106","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v8.11.0","v8.12.0","v8.11.1"],"number":170092,"url":"https://github.com/elastic/kibana/pull/170092","mergeCommit":{"message":"[Obs
AI Assistant] Use ELSER v2 (elastic#170092)\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"beae7b1448d00f95c3e89ccd6f62c38d5a973106"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170092","number":170092,"mergeCommit":{"message":"[Obs
AI Assistant] Use ELSER v2 (elastic#170092)\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"beae7b1448d00f95c3e89ccd6f62c38d5a973106"}}]}]
BACKPORT-->

Co-authored-by: Dario Gieselaar <[email protected]>
  • Loading branch information
kibanamachine and dgieselaar authored Oct 31, 2023
1 parent 5092643 commit 5312779
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function getResourceName(resource: string) {
return `.kibana-observability-ai-assistant-${resource}`;
}

export const ELSER_MODEL_ID = '.elser_model_2';

export const INDEX_QUEUED_DOCUMENTS_TASK_ID = 'observabilityAIAssistant:indexQueuedDocumentsTask';

export const INDEX_QUEUED_DOCUMENTS_TASK_TYPE = INDEX_QUEUED_DOCUMENTS_TASK_ID + 'Type';
Expand Down Expand Up @@ -120,6 +122,11 @@ export class ObservabilityAIAssistantService {
auto_expand_replicas: '0-1',
hidden: true,
},
mappings: {
_meta: {
model: ELSER_MODEL_ID,
},
},
},
});

Expand Down Expand Up @@ -150,7 +157,7 @@ export class ObservabilityAIAssistantService {
processors: [
{
inference: {
model_id: '.elser_model_1',
model_id: ELSER_MODEL_ID,
target_field: 'ml',
field_map: {
text: 'text_field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import type { TaskManagerStartContract } from '@kbn/task-manager-plugin/server';
import pLimit from 'p-limit';
import pRetry from 'p-retry';
import { map } from 'lodash';
import { INDEX_QUEUED_DOCUMENTS_TASK_ID, INDEX_QUEUED_DOCUMENTS_TASK_TYPE } from '..';
import {
ELSER_MODEL_ID,
INDEX_QUEUED_DOCUMENTS_TASK_ID,
INDEX_QUEUED_DOCUMENTS_TASK_TYPE,
} from '..';
import type { KnowledgeBaseEntry } from '../../../common/types';
import type { ObservabilityAIAssistantResourceNames } from '../types';
import { getAccessQuery } from '../util/get_access_query';
Expand Down Expand Up @@ -42,8 +46,6 @@ function isAlreadyExistsError(error: Error) {
);
}

const ELSER_MODEL_ID = '.elser_model_1';

function throwKnowledgeBaseNotReady(body: any) {
throw serverUnavailable(`Knowledge base is not ready yet`, body);
}
Expand Down Expand Up @@ -199,7 +201,7 @@ export class KnowledgeBaseService {
text_expansion: {
'ml.tokens': {
model_text: text,
model_id: '.elser_model_1',
model_id: ELSER_MODEL_ID,
},
} as unknown as QueryDslTextExpansionQuery,
})),
Expand Down

0 comments on commit 5312779

Please sign in to comment.