diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/semantic_text.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/semantic_text.tsx index 5ec9216f599c6..c1f56214e2ce1 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/semantic_text.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/combined_fields/semantic_text.tsx @@ -41,8 +41,8 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision const { services: { http }, } = useDataVisualizerKibana(); - const [inferenceServices, setInferenceServices] = useState([]); - const [selectedInference, setSelectedInference] = useState(); + const [inferenceEndpoints, setInferenceEndpoints] = useState([]); + const [selectedInferenceEndpoint, setSelectedInferenceEndpoint] = useState(); const [selectedFieldOption, setSelectedFieldOption] = useState(); const [renameToFieldOption, setRenameToFieldOption] = useState(''); const [fieldError, setFieldError] = useState(); @@ -61,17 +61,17 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision useEffect(() => { http - .fetch('/internal/data_visualizer/inference_services', { + .fetch('/internal/data_visualizer/inference_endpoints', { method: 'GET', version: '1', }) .then((response) => { - const inferenceServiceOptions = response.map((service) => ({ - value: service.inference_id, - text: service.inference_id, + const inferenceEndpointOptions = response.map((endpoint) => ({ + value: endpoint.inference_id, + text: endpoint.inference_id, })); - setInferenceServices(inferenceServiceOptions); - setSelectedInference(inferenceServiceOptions[0]?.value ?? undefined); + setInferenceEndpoints(inferenceEndpointOptions); + setSelectedInferenceEndpoint(inferenceEndpointOptions[0]?.value ?? undefined); }); }, [http]); @@ -88,7 +88,7 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision renameToFieldOption === '' || renameToFieldOption === undefined || selectedFieldOption === undefined || - selectedInference === undefined + selectedInferenceEndpoint === undefined ) { return; } @@ -103,7 +103,7 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision newMappings.properties![renameToFieldOption ?? selectedFieldOption] = { // @ts-ignore types are missing semantic_text type: 'semantic_text', - inference_id: selectedInference, + inference_id: selectedInferenceEndpoint, }; return newMappings; }, @@ -138,12 +138,12 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision const isInvalid = useMemo(() => { return ( - !selectedInference || + !selectedInferenceEndpoint || !selectedFieldOption || renameToFieldOption === '' || fieldError !== undefined ); - }, [selectedInference, selectedFieldOption, renameToFieldOption, fieldError]); + }, [selectedInferenceEndpoint, selectedFieldOption, renameToFieldOption, fieldError]); return ( <> @@ -185,13 +185,13 @@ export const SemanticTextForm: FC = ({ addCombinedField, hasNameCollision setSelectedInference(e.target.value)} + options={inferenceEndpoints} + value={selectedInferenceEndpoint} + onChange={(e) => setSelectedInferenceEndpoint(e.target.value)} /> diff --git a/x-pack/plugins/data_visualizer/server/routes.ts b/x-pack/plugins/data_visualizer/server/routes.ts index 05234fc5583ee..e04ba7521bfa4 100644 --- a/x-pack/plugins/data_visualizer/server/routes.ts +++ b/x-pack/plugins/data_visualizer/server/routes.ts @@ -67,9 +67,16 @@ export function routes(coreSetup: CoreSetup, logger: Logger) } ); + /** + * @apiGroup DataVisualizer + * + * @api {get} /internal/data_visualizer/inference_endpoints Returns a list of inference endpoints which are currently deployed + * @apiName inferenceEndpoints + * @apiDescription Returns a list of inference endpoints where the underlying model is currently deployed + */ router.versioned .get({ - path: '/internal/data_visualizer/inference_services', + path: '/internal/data_visualizer/inference_endpoints', access: 'internal', options: { tags: ['access:fileUpload:analyzeFile'], @@ -87,7 +94,15 @@ export function routes(coreSetup: CoreSetup, logger: Logger) inference_id: '_all', }); - return response.ok({ body: endpoints }); + const filteredInferenceEndpoints = endpoints.filter((endpoint) => { + return ( + endpoint.task_type === 'sparse_embedding' || endpoint.task_type === 'text_embedding' + // TODO: add this back in when the fix has made it into es in 8.16 + // && endpoint.service_settings.num_allocations > 0 + ); + }); + + return response.ok({ body: filteredInferenceEndpoints }); } catch (e) { return response.customError(wrapError(e)); }