Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints #196577

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision
const {
services: { http },
} = useDataVisualizerKibana();
const [inferenceServices, setInferenceServices] = useState<EuiSelectOption[]>([]);
const [selectedInference, setSelectedInference] = useState<string | undefined>();
const [inferenceEndpoints, setInferenceEndpoints] = useState<EuiSelectOption[]>([]);
const [selectedInferenceEndpoint, setSelectedInferenceEndpoint] = useState<string | undefined>();
const [selectedFieldOption, setSelectedFieldOption] = useState<string | undefined>();
const [renameToFieldOption, setRenameToFieldOption] = useState<string>('');
const [fieldError, setFieldError] = useState<string | undefined>();
Expand All @@ -61,17 +61,17 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision

useEffect(() => {
http
.fetch<InferenceInferenceEndpointInfo[]>('/internal/data_visualizer/inference_services', {
.fetch<InferenceInferenceEndpointInfo[]>('/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]);

Expand All @@ -88,7 +88,7 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision
renameToFieldOption === '' ||
renameToFieldOption === undefined ||
selectedFieldOption === undefined ||
selectedInference === undefined
selectedInferenceEndpoint === undefined
) {
return;
}
Expand All @@ -103,7 +103,7 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision
newMappings.properties![renameToFieldOption ?? selectedFieldOption] = {
// @ts-ignore types are missing semantic_text
type: 'semantic_text',
inference_id: selectedInference,
inference_id: selectedInferenceEndpoint,
};
return newMappings;
},
Expand Down Expand Up @@ -138,12 +138,12 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision

const isInvalid = useMemo(() => {
return (
!selectedInference ||
!selectedInferenceEndpoint ||
!selectedFieldOption ||
renameToFieldOption === '' ||
fieldError !== undefined
);
}, [selectedInference, selectedFieldOption, renameToFieldOption, fieldError]);
}, [selectedInferenceEndpoint, selectedFieldOption, renameToFieldOption, fieldError]);

return (
<>
Expand Down Expand Up @@ -185,13 +185,13 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision

<EuiFormRow
label={i18n.translate('xpack.dataVisualizer.file.semanticTextForm.inferenceLabel', {
defaultMessage: 'Inference service',
defaultMessage: 'Inference endpoint',
})}
>
<EuiSelect
options={inferenceServices}
value={selectedInference}
onChange={(e) => setSelectedInference(e.target.value)}
options={inferenceEndpoints}
value={selectedInferenceEndpoint}
onChange={(e) => setSelectedInferenceEndpoint(e.target.value)}
/>
</EuiFormRow>

Expand Down
19 changes: 17 additions & 2 deletions x-pack/plugins/data_visualizer/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ export function routes(coreSetup: CoreSetup<StartDeps, unknown>, 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'],
Expand All @@ -87,7 +94,15 @@ export function routes(coreSetup: CoreSetup<StartDeps, unknown>, 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));
}
Expand Down