mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Display only text_embedding and sparse_embedding related inference endpoints (#189455)
This PR resolves https://github.com/elastic/search-team/issues/7989 In the semantic_text UI, we should display the inference endpoints related to text_embedding and sparse_embedding only. ### Before  ### After 
This commit is contained in:
parent
3a19c3501c
commit
39bde9d4eb
2 changed files with 23 additions and 2 deletions
|
@ -16,6 +16,7 @@ import {
|
|||
SelectInferenceIdProps,
|
||||
} from '../../../public/application/components/mappings_editor/components/document_fields/field_parameters/select_inference_id';
|
||||
import React from 'react';
|
||||
import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
|
||||
|
||||
const createInferenceEndpointMock = jest.fn();
|
||||
const mockDispatch = jest.fn();
|
||||
|
@ -60,6 +61,18 @@ jest.mock('../../../public/application/components/mappings_editor/mappings_state
|
|||
useDispatch: () => mockDispatch,
|
||||
}));
|
||||
|
||||
jest.mock('../../../public/application/services/api', () => ({
|
||||
useLoadInferenceEndpoints: jest.fn().mockReturnValue({
|
||||
data: [
|
||||
{ model_id: 'endpoint-1', task_type: 'text_embedding' },
|
||||
{ model_id: 'endpoint-2', task_type: 'sparse_embedding' },
|
||||
{ model_id: 'endpoint-3', task_type: 'completion' },
|
||||
] as InferenceAPIConfigResponse[],
|
||||
isLoading: false,
|
||||
error: null,
|
||||
}),
|
||||
}));
|
||||
|
||||
function getTestForm(Component: React.FC<SelectInferenceIdProps>) {
|
||||
return (defaultProps: SelectInferenceIdProps) => {
|
||||
const { form } = useForm();
|
||||
|
@ -107,5 +120,8 @@ describe('SelectInferenceId', () => {
|
|||
find('inferenceIdButton').simulate('click');
|
||||
expect(find('data-inference-endpoint-list').contains('e5')).toBe(true);
|
||||
expect(find('data-inference-endpoint-list').contains('elser_model_2')).toBe(true);
|
||||
expect(find('data-inference-endpoint-list').contains('endpoint-1')).toBe(true);
|
||||
expect(find('data-inference-endpoint-list').contains('endpoint-2')).toBe(true);
|
||||
expect(find('data-inference-endpoint-list').contains('endpoint-3')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -133,11 +133,16 @@ const SelectInferenceIdContent: React.FC<SelectInferenceIdContentProps> = ({
|
|||
const { isLoading, data: endpoints, resendRequest } = useLoadInferenceEndpoints();
|
||||
|
||||
const options: EuiSelectableOption[] = useMemo(() => {
|
||||
const filteredEndpoints = endpoints?.filter(
|
||||
(endpoint) =>
|
||||
endpoint.task_type === 'text_embedding' || endpoint.task_type === 'sparse_embedding'
|
||||
);
|
||||
|
||||
const missingDefaultEndpoints = defaultEndpoints.filter(
|
||||
(endpoint) => !(endpoints || []).find((e) => e.model_id === endpoint.model_id)
|
||||
(endpoint) => !(filteredEndpoints || []).find((e) => e.model_id === endpoint.model_id)
|
||||
);
|
||||
const newOptions: EuiSelectableOption[] = [
|
||||
...(endpoints || []),
|
||||
...(filteredEndpoints || []),
|
||||
...missingDefaultEndpoints,
|
||||
].map((endpoint) => ({
|
||||
label: endpoint.model_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue