mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.16] [ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints (#196577) (#197030)
# Backport This will backport the following commits from `main` to `8.16`: - [[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints (#196577)](https://github.com/elastic/kibana/pull/196577) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"James Gowdy","email":"jgowdy@elastic.co"},"sourceCommit":{"committedDate":"2024-10-21T10:56:05Z","message":"[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints (#196577)\n\nWhen listing the inference endpoints available for the semantic text\r\nfield, we should only list `sparse_embedding` and `text_embedding`\r\ntypes.\r\n\r\n<img width=\"353\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/95526f2b-e293-4e01-be79-b87e1ecb9a75\">\r\n\r\n\r\n\r\nThis PR adds a check to the `data_visualizer/inference_endpoints`\r\nendpoint to ensure only `sparse_embedding` and `text_embedding` types\r\nare used and they have at least one allocation.\r\nNOTE, the allocation check is currently commented out waiting on an es\r\nchange. https://github.com/elastic/elasticsearch/pull/115095\r\n\r\nAlso renames the endpoint from `data_visualizer/inference_services` ->\r\n`data_visualizer/inference_endpoints`\r\nAnd renames variables which were incorrectly named \"service\" rather than\r\n\"endpoint\"","sha":"fb412ca0b7dfb997f2f84da62a12f32d3012ffb0","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug",":ml","release_note:skip","Feature:File and Index Data Viz","Feature:File Upload","v9.0.0","v8.16.0","backport:version","v8.17.0"],"title":"[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints","number":196577,"url":"https://github.com/elastic/kibana/pull/196577","mergeCommit":{"message":"[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints (#196577)\n\nWhen listing the inference endpoints available for the semantic text\r\nfield, we should only list `sparse_embedding` and `text_embedding`\r\ntypes.\r\n\r\n<img width=\"353\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/95526f2b-e293-4e01-be79-b87e1ecb9a75\">\r\n\r\n\r\n\r\nThis PR adds a check to the `data_visualizer/inference_endpoints`\r\nendpoint to ensure only `sparse_embedding` and `text_embedding` types\r\nare used and they have at least one allocation.\r\nNOTE, the allocation check is currently commented out waiting on an es\r\nchange. https://github.com/elastic/elasticsearch/pull/115095\r\n\r\nAlso renames the endpoint from `data_visualizer/inference_services` ->\r\n`data_visualizer/inference_endpoints`\r\nAnd renames variables which were incorrectly named \"service\" rather than\r\n\"endpoint\"","sha":"fb412ca0b7dfb997f2f84da62a12f32d3012ffb0"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196577","number":196577,"mergeCommit":{"message":"[ML] File data visualizer: only list sparse_embedding and text_embedding inference endpoints (#196577)\n\nWhen listing the inference endpoints available for the semantic text\r\nfield, we should only list `sparse_embedding` and `text_embedding`\r\ntypes.\r\n\r\n<img width=\"353\" alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/95526f2b-e293-4e01-be79-b87e1ecb9a75\">\r\n\r\n\r\n\r\nThis PR adds a check to the `data_visualizer/inference_endpoints`\r\nendpoint to ensure only `sparse_embedding` and `text_embedding` types\r\nare used and they have at least one allocation.\r\nNOTE, the allocation check is currently commented out waiting on an es\r\nchange. https://github.com/elastic/elasticsearch/pull/115095\r\n\r\nAlso renames the endpoint from `data_visualizer/inference_services` ->\r\n`data_visualizer/inference_endpoints`\r\nAnd renames variables which were incorrectly named \"service\" rather than\r\n\"endpoint\"","sha":"fb412ca0b7dfb997f2f84da62a12f32d3012ffb0"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
parent
76993eb1f6
commit
6d77db490f
2 changed files with 33 additions and 18 deletions
|
@ -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>();
|
||||
|
@ -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]);
|
||||
|
||||
|
@ -88,7 +88,7 @@ export const SemanticTextForm: FC<Props> = ({ addCombinedField, hasNameCollision
|
|||
renameToFieldOption === '' ||
|
||||
renameToFieldOption === undefined ||
|
||||
selectedFieldOption === undefined ||
|
||||
selectedInference === undefined
|
||||
selectedInferenceEndpoint === undefined
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -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;
|
||||
},
|
||||
|
@ -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 (
|
||||
<>
|
||||
|
@ -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>
|
||||
|
||||
|
|
|
@ -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'],
|
||||
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue