diff --git a/x-pack/platform/packages/shared/ml/trained_models_utils/src/constants/trained_models.ts b/x-pack/platform/packages/shared/ml/trained_models_utils/src/constants/trained_models.ts index e634cf37b27c0..1e5073d803093 100644 --- a/x-pack/platform/packages/shared/ml/trained_models_utils/src/constants/trained_models.ts +++ b/x-pack/platform/packages/shared/ml/trained_models_utils/src/constants/trained_models.ts @@ -223,7 +223,7 @@ export interface GetModelDownloadConfigOptions { } export interface LocalInferenceServiceSettings { - service: 'elser' | 'elasticsearch'; + service: 'elasticsearch'; service_settings: { num_allocations: number; num_threads: number; diff --git a/x-pack/platform/plugins/shared/index_management/public/hooks/use_details_page_mappings_model_management.ts b/x-pack/platform/plugins/shared/index_management/public/hooks/use_details_page_mappings_model_management.ts index 7a8d9f526b9f0..411e0bc8bde39 100644 --- a/x-pack/platform/plugins/shared/index_management/public/hooks/use_details_page_mappings_model_management.ts +++ b/x-pack/platform/plugins/shared/index_management/public/hooks/use_details_page_mappings_model_management.ts @@ -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], diff --git a/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.test.ts b/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.test.ts deleted file mode 100644 index 92f3cc23da75b..0000000000000 --- a/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 { addInferenceEndpoint } from './add_inference_endpoint'; - -describe('addInferenceEndpoint', () => { - const mockClient: any = { - inference: { - put: jest.fn(), - }, - }; - - const config: any = { - provider: 'elasticsearch', - taskType: 'text_embedding', - inferenceId: 'es-endpoint-1', - providerConfig: { - num_allocations: 1, - num_threads: 2, - model_id: '.multilingual-e5-small', - }, - }; - const secrets: any = { providerSecrets: {} }; - - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('should call the ES client with correct PUT request', async () => { - await addInferenceEndpoint(mockClient, config, secrets); - - expect(mockClient.inference.put).toHaveBeenCalledWith({ - inference_id: config.inferenceId, - task_type: config.taskType, - inference_config: { - service: 'elasticsearch', - service_settings: { - num_allocations: 1, - num_threads: 2, - model_id: '.multilingual-e5-small', - }, - task_settings: {}, - }, - }); - }); -}); diff --git a/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.ts b/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.ts deleted file mode 100644 index cf36c9bad197d..0000000000000 --- a/x-pack/platform/plugins/shared/inference_endpoint/server/lib/add_inference_endpoint.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 { InferenceTaskType } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { Config, Secrets } from '@kbn/inference-endpoint-ui-common'; -import { ElasticsearchClient } from '@kbn/core/server'; -import { unflattenObject } from '../utils/unflatten_object'; - -export const addInferenceEndpoint = async ( - esClient: ElasticsearchClient, - config: Config, - secrets: Secrets -) => { - /* task settings property is required in the API call - but no needed for inference or connector creation - */ - const taskSettings = {}; - const serviceSettings = { - ...unflattenObject(config?.providerConfig ?? {}), - ...unflattenObject(secrets?.providerSecrets ?? {}), - }; - - return await esClient.inference.put({ - inference_id: config?.inferenceId ?? '', - task_type: config?.taskType as InferenceTaskType, - inference_config: { - service: config?.provider, - service_settings: serviceSettings, - task_settings: taskSettings, - }, - }); -}; diff --git a/x-pack/platform/plugins/shared/inference_endpoint/server/routes/index.ts b/x-pack/platform/plugins/shared/inference_endpoint/server/routes/index.ts index 17d1715f91fc6..e634910300ae4 100644 --- a/x-pack/platform/plugins/shared/inference_endpoint/server/routes/index.ts +++ b/x-pack/platform/plugins/shared/inference_endpoint/server/routes/index.ts @@ -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({ @@ -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, diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/alibaba_cloud_ai_search.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/alibaba_cloud_ai_search.svg deleted file mode 100644 index 18534e2d0b3a1..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/alibaba_cloud_ai_search.svg +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/amazon_bedrock.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/amazon_bedrock.svg deleted file mode 100644 index f8815d4f75ec5..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/amazon_bedrock.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_ai_studio.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_ai_studio.svg deleted file mode 100644 index 405e182a10394..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_ai_studio.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_open_ai.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_open_ai.svg deleted file mode 100644 index 122c0c65af13c..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/azure_open_ai.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/cohere.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/cohere.svg deleted file mode 100644 index 69953809fec35..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/cohere.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/elastic.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/elastic.svg deleted file mode 100644 index e763c2e2f2ab6..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/elastic.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/google_ai_studio.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/google_ai_studio.svg deleted file mode 100644 index b6e34ae15c9e4..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/google_ai_studio.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/hugging_face.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/hugging_face.svg deleted file mode 100644 index 87ac70c5a18f4..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/hugging_face.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/jinaai.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/jinaai.svg deleted file mode 100644 index 605c0cff86942..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/jinaai.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - Jina-color - - - - - - - - - - \ No newline at end of file diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/mistral.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/mistral.svg deleted file mode 100644 index f62258a327594..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/mistral.svg +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/open_ai.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/open_ai.svg deleted file mode 100644 index 9ddc8f8fd63b8..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/open_ai.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/watsonx_ai.svg b/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/watsonx_ai.svg deleted file mode 100644 index 29f7a735e6614..0000000000000 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/assets/images/providers/watsonx_ai.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/filter/service_provider_filter.tsx b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/filter/service_provider_filter.tsx index 56420f98bfac7..ebc795258245a 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/filter/service_provider_filter.tsx +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/filter/service_provider_filter.tsx @@ -6,8 +6,8 @@ */ import React from 'react'; -import { SERVICE_PROVIDERS } from '../render_table_columns/render_service_provider/service_provider'; -import type { FilterOptions, ServiceProviderKeys } from '../types'; +import { SERVICE_PROVIDERS, ServiceProviderKeys } from '@kbn/inference-endpoint-ui-common'; +import type { FilterOptions } from '../types'; import { MultiSelectFilter, MultiSelectFilterOption } from './multi_select_filter'; import * as i18n from './translations'; diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_service_provider/service_provider.tsx b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_service_provider/service_provider.tsx index 60be14246d522..bd5f330431a88 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_service_provider/service_provider.tsx +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/render_table_columns/render_service_provider/service_provider.tsx @@ -11,84 +11,13 @@ import { ELASTIC_MODEL_DEFINITIONS, InferenceAPIConfigResponse, } from '@kbn/ml-trained-models-utils'; -import elasticIcon from '../../../../assets/images/providers/elastic.svg'; -import huggingFaceIcon from '../../../../assets/images/providers/hugging_face.svg'; -import cohereIcon from '../../../../assets/images/providers/cohere.svg'; -import openAIIcon from '../../../../assets/images/providers/open_ai.svg'; -import azureAIStudioIcon from '../../../../assets/images/providers/azure_ai_studio.svg'; -import azureOpenAIIcon from '../../../../assets/images/providers/azure_open_ai.svg'; -import googleAIStudioIcon from '../../../../assets/images/providers/google_ai_studio.svg'; -import mistralIcon from '../../../../assets/images/providers/mistral.svg'; -import amazonBedrockIcon from '../../../../assets/images/providers/amazon_bedrock.svg'; -import alibabaCloudAISearchIcon from '../../../../assets/images/providers/alibaba_cloud_ai_search.svg'; -import watsonxAIIcon from '../../../../assets/images/providers/watsonx_ai.svg'; -import { ServiceProviderKeys } from '../../types'; +import { SERVICE_PROVIDERS, ServiceProviderKeys } from '@kbn/inference-endpoint-ui-common'; import * as i18n from './translations'; interface ServiceProviderProps { providerEndpoint: InferenceAPIConfigResponse; } -interface ServiceProviderRecord { - icon: string; - name: string; -} - -export const SERVICE_PROVIDERS: Record = { - [ServiceProviderKeys['alibabacloud-ai-search']]: { - icon: alibabaCloudAISearchIcon, - name: 'AlibabaCloud AI Search', - }, - [ServiceProviderKeys.amazonbedrock]: { - icon: amazonBedrockIcon, - name: 'Amazon Bedrock', - }, - [ServiceProviderKeys.azureaistudio]: { - icon: azureAIStudioIcon, - name: 'Azure AI Studio', - }, - [ServiceProviderKeys.azureopenai]: { - icon: azureOpenAIIcon, - name: 'Azure OpenAI', - }, - [ServiceProviderKeys.cohere]: { - icon: cohereIcon, - name: 'Cohere', - }, - [ServiceProviderKeys.elasticsearch]: { - icon: elasticIcon, - name: 'Elasticsearch', - }, - [ServiceProviderKeys.elastic]: { - icon: elasticIcon, - name: 'Elastic', - }, - [ServiceProviderKeys.elser]: { - icon: elasticIcon, - name: 'Elasticsearch', - }, - [ServiceProviderKeys.googleaistudio]: { - icon: googleAIStudioIcon, - name: 'Google AI Studio', - }, - [ServiceProviderKeys.hugging_face]: { - icon: huggingFaceIcon, - name: 'Hugging Face', - }, - [ServiceProviderKeys.mistral]: { - icon: mistralIcon, - name: 'Mistral', - }, - [ServiceProviderKeys.openai]: { - icon: openAIIcon, - name: 'OpenAI', - }, - [ServiceProviderKeys.watsonxai]: { - icon: watsonxAIIcon, - name: 'WatsonxAI', - }, -}; - export const ServiceProvider: React.FC = ({ providerEndpoint }) => { const { service } = providerEndpoint; const provider = SERVICE_PROVIDERS[service]; diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx index 09e1844077c23..a026088044e0a 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/tabular_page.test.tsx @@ -15,7 +15,7 @@ const inferenceEndpoints = [ { inference_id: 'my-elser-model-05', task_type: 'sparse_embedding', - service: 'elser', + service: 'elasticsearch', service_settings: { num_allocations: 1, num_threads: 1, diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/types.ts b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/types.ts index 4fe526b2bbf1b..2d2a8af8da177 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/types.ts +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/components/all_inference_endpoints/types.ts @@ -6,25 +6,10 @@ */ import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils'; +import { ServiceProviderKeys } from '@kbn/inference-endpoint-ui-common'; import { TaskTypes } from '../../types'; export const INFERENCE_ENDPOINTS_TABLE_PER_PAGE_VALUES = [25, 50, 100]; -export enum ServiceProviderKeys { - 'alibabacloud-ai-search' = 'alibabacloud-ai-search', - amazonbedrock = 'amazonbedrock', - azureopenai = 'azureopenai', - azureaistudio = 'azureaistudio', - cohere = 'cohere', - elasticsearch = 'elasticsearch', - elastic = 'elastic', - elser = 'elser', - googleaistudio = 'googleaistudio', - hugging_face = 'hugging_face', - mistral = 'mistral', - openai = 'openai', - watsonxai = 'watsonxai', -} - export enum SortFieldInferenceEndpoint { endpoint = 'endpoint', } diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.test.tsx b/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.test.tsx index c5d3cf15f1407..ce972a7d04ad4 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.test.tsx +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.test.tsx @@ -18,7 +18,7 @@ const inferenceEndpoints = [ { inference_id: 'my-elser-model-04', task_type: 'sparse_embedding', - service: 'elser', + service: 'elasticsearch', service_settings: { num_allocations: 1, num_threads: 1, @@ -29,7 +29,7 @@ const inferenceEndpoints = [ { inference_id: 'my-elser-model-01', task_type: 'sparse_embedding', - service: 'elser', + service: 'elasticsearch', service_settings: { num_allocations: 1, num_threads: 1, @@ -38,13 +38,12 @@ const inferenceEndpoints = [ task_settings: {}, }, { - inference_id: 'my-elser-model-05', + inference_id: 'my-openai-model-05', task_type: 'text_embedding', - service: 'elasticsearch', + service: 'openai', service_settings: { - num_allocations: 1, - num_threads: 1, - model_id: '.elser_model_2', + url: 'https://somewhere.com', + model_id: 'third-party-model', }, task_settings: {}, }, @@ -58,7 +57,7 @@ const queryParams = { } as QueryParams; const filterOptions = { - provider: ['elser', 'elasticsearch'], + provider: ['elasticsearch', 'openai'], type: ['sparse_embedding', 'text_embedding'], } as any; @@ -126,7 +125,7 @@ describe('useTableData', () => { it('should filter data based on provider and type from filterOptions', () => { const filterOptions2 = { - provider: ['elser'], + provider: ['elasticsearch'], type: ['text_embedding'], } as any; const { result } = renderHook( diff --git a/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.tsx b/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.tsx index 775bea270559d..c2d54dd738eac 100644 --- a/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.tsx +++ b/x-pack/solutions/search/plugins/search_inference_endpoints/public/hooks/use_table_data.tsx @@ -9,6 +9,7 @@ import type { EuiTableSortingType } from '@elastic/eui'; import { Pagination } from '@elastic/eui'; import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils'; import { useMemo } from 'react'; +import { ServiceProviderKeys } from '@kbn/inference-endpoint-ui-common'; import { TaskTypes } from '../../common/types'; import { DEFAULT_TABLE_LIMIT } from '../components/all_inference_endpoints/constants'; import { @@ -17,7 +18,6 @@ import { InferenceEndpointUI, QueryParams, SortOrder, - ServiceProviderKeys, } from '../components/all_inference_endpoints/types'; interface UseTableDataReturn {