Skip to content

Commit

Permalink
[8.18] [Search] Fix Add Inference Endpoint API call (#210243) (#210624)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.18`:
- [[Search] Fix Add Inference Endpoint API call
(#210243)](#210243)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-11T16:04:58Z","message":"[Search]
Fix Add Inference Endpoint API call (#210243)\n\n## Summary\r\n\r\nThis
PR includes\r\n- Remove `task_settings` from API call\r\n- Remove
`Service_providers` definition from the plugin to use the\r\nglobal
definition.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [X] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"2e29a504a749c5ce4bd2f167e38d13e4a7952485","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:ML","ci:project-deploy-elasticsearch","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Search]
Fix Add Inference Endpoint API
call","number":210243,"url":"https://github.com/elastic/kibana/pull/210243","mergeCommit":{"message":"[Search]
Fix Add Inference Endpoint API call (#210243)\n\n## Summary\r\n\r\nThis
PR includes\r\n- Remove `task_settings` from API call\r\n- Remove
`Service_providers` definition from the plugin to use the\r\nglobal
definition.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [X] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"2e29a504a749c5ce4bd2f167e38d13e4a7952485"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210243","number":210243,"mergeCommit":{"message":"[Search]
Fix Add Inference Endpoint API call (#210243)\n\n## Summary\r\n\r\nThis
PR includes\r\n- Remove `task_settings` from API call\r\n- Remove
`Service_providers` definition from the plugin to use the\r\nglobal
definition.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [X] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[X] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"2e29a504a749c5ce4bd2f167e38d13e4a7952485"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Samiul Monir <[email protected]>
  • Loading branch information
kibanamachine and Samiul-TheSoccerFan authored Feb 11, 2025
1 parent cfced04 commit ad27805
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export interface GetModelDownloadConfigOptions {
}

export interface LocalInferenceServiceSettings {
service: 'elser' | 'elasticsearch';
service: 'elasticsearch';
service_settings: {
num_allocations: number;
num_threads: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getCustomInferenceIdMap = (
const inferenceEntry = isLocalModel(model)
? {
trainedModelId: model.service_settings.model_id,
isDeployable: model.service === Service.elser || model.service === Service.elasticsearch,
isDeployable: model.service === Service.elasticsearch,
isDeployed: modelStatsById[model.inference_id]?.state === 'started',
isDownloading: Boolean(downloadStates[model.service_settings.model_id]),
modelStats: modelStatsById[model.inference_id],
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import type { IKibanaResponse, IRouter, RequestHandlerContext } from '@kbn/core/server';
import { Logger } from '@kbn/logging';
import { schema } from '@kbn/config-schema';
import { InferenceInferenceEndpointInfo } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
InferenceInferenceEndpointInfo,
InferenceTaskType,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { InferenceServicesGetResponse } from '../types';
import { INFERENCE_ENDPOINT_INTERNAL_API_VERSION } from '../../common';
import { addInferenceEndpoint } from '../lib/add_inference_endpoint';
import { inferenceEndpointExists } from '../lib/inference_endpoint_exists';
import { unflattenObject } from '../utils/unflatten_object';

const inferenceEndpointSchema = schema.object({
config: schema.object({
Expand Down Expand Up @@ -90,7 +93,20 @@ export const getInferenceServicesRoute = (
const esClient = (await context.core).elasticsearch.client.asCurrentUser;

const { config, secrets } = request.body;
const result = await addInferenceEndpoint(esClient, config, secrets);

const serviceSettings = {
...unflattenObject(config?.providerConfig ?? {}),
...unflattenObject(secrets?.providerSecrets ?? {}),
};

const result = await esClient.inference.put({
inference_id: config?.inferenceId ?? '',
task_type: config?.taskType as InferenceTaskType,
inference_config: {
service: config?.provider,
service_settings: serviceSettings,
},
});

return response.ok({
body: result,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ad27805

Please sign in to comment.