mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Add inference endpoints management page
This commit is contained in:
parent
8c6f6d8c13
commit
2908664d1a
5 changed files with 139 additions and 4 deletions
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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 { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
|
||||
|
||||
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
|
||||
import { HttpLogic } from '../../../shared/http';
|
||||
|
||||
export interface FetchInferenceEndpointsResponse {
|
||||
inference_endpoints: InferenceAPIConfigResponse[];
|
||||
}
|
||||
|
||||
export const fetchInferenceEndpoints = async (): Promise<FetchInferenceEndpointsResponse> => {
|
||||
const { http } = HttpLogic.values;
|
||||
const route = '/internal/enterprise_search/inference_endpoints';
|
||||
const response = await http.get<{
|
||||
inference_endpoints: InferenceAPIConfigResponse[];
|
||||
}>(route);
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
export const FetchInferenceEndpointsAPILogic = createApiLogic(
|
||||
['content', 'inference_endpoints_api_logic'],
|
||||
fetchInferenceEndpoints
|
||||
);
|
||||
|
||||
export type FetchInferenceEdnpointsApiActions = Actions<{}, FetchInferenceEndpointsResponse>;
|
|
@ -5,9 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { useEffect, useMemo, useState, useCallback } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { useValues } from 'kea';
|
||||
import { useActions, useValues } from 'kea';
|
||||
|
||||
import { InferenceTaskType } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
|
@ -24,10 +24,9 @@ import { docLinks } from '../../../shared/doc_links';
|
|||
import { KibanaLogic } from '../../../shared/kibana';
|
||||
|
||||
import { EmptyPromptPage } from './empty_prompt_page';
|
||||
import { InferenceEndpointsLogic } from './inference_endpoints_logic';
|
||||
import { TabularPage } from './tabular_page';
|
||||
|
||||
const inferenceEndpoints = [];
|
||||
|
||||
const inferenceEndpointsBreadcrumbs = [
|
||||
i18n.translate('xpack.enterpriseSearch.content.inferenceEndpoints.breadcrumb', {
|
||||
defaultMessage: 'Inference Endpoints',
|
||||
|
@ -43,6 +42,8 @@ const addEndpointLabel = i18n.translate(
|
|||
|
||||
export const InferenceEndpoints: React.FC = () => {
|
||||
const { ml } = useValues(KibanaLogic);
|
||||
const { fetchInferenceEndpoints } = useActions(InferenceEndpointsLogic);
|
||||
const { inferenceEndpoints } = useValues(InferenceEndpointsLogic);
|
||||
const [isInferenceFlyoutVisible, setIsInferenceFlyoutVisible] = useState<boolean>(false);
|
||||
const [inferenceAddError, setInferenceAddError] = useState<string | undefined>(undefined);
|
||||
const [isCreateInferenceApiLoading, setIsCreateInferenceApiLoading] = useState(false);
|
||||
|
@ -80,6 +81,10 @@ export const InferenceEndpoints: React.FC = () => {
|
|||
setIsInferenceFlyoutVisible(!isInferenceFlyoutVisible);
|
||||
}, [isInferenceFlyoutVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchInferenceEndpoints();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAvailableTrainedModels = async () => {
|
||||
setAvailableTrainedModels((await ml?.mlApi?.trainedModels?.getTrainedModels()) ?? []);
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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 { kea, MakeLogicType } from 'kea';
|
||||
|
||||
import {
|
||||
CancelSyncsActions,
|
||||
CancelSyncsApiLogic,
|
||||
} from '../../api/connector/cancel_syncs_api_logic';
|
||||
import { FetchInferenceEndpointsAPILogic } from '../../api/inference_endpoints/fetch_inference_endpoints_api_logic';
|
||||
|
||||
import { FetchInferenceEdnpointsApiActions as FetchInferenceEndpointsApiActions } from '../../api/inference_endpoints/fetch_inference_endpoints_api_logic';
|
||||
import { ElasticsearchViewIndex } from '../../types';
|
||||
|
||||
export interface InferenceEndpointsActions {
|
||||
apiError: FetchInferenceEndpointsApiActions['apiError'];
|
||||
apiSuccess: FetchInferenceEndpointsApiActions['apiSuccess'];
|
||||
cancelSuccess: CancelSyncsActions['apiSuccess'];
|
||||
fetchInferenceEndpoints: () => {};
|
||||
makeRequest: FetchInferenceEndpointsApiActions['makeRequest'];
|
||||
}
|
||||
export interface InferenceEndpointsValues {
|
||||
data: typeof FetchInferenceEndpointsAPILogic.values.data;
|
||||
inferenceEndpoints: ElasticsearchViewIndex[];
|
||||
status: typeof FetchInferenceEndpointsAPILogic.values.status;
|
||||
}
|
||||
|
||||
export const InferenceEndpointsLogic = kea<
|
||||
MakeLogicType<InferenceEndpointsValues, InferenceEndpointsActions>
|
||||
>({
|
||||
actions: {
|
||||
fetchInferenceEndpoints: () => ({}),
|
||||
},
|
||||
connect: {
|
||||
actions: [
|
||||
CancelSyncsApiLogic,
|
||||
['apiSuccess as cancelSuccess'],
|
||||
FetchInferenceEndpointsAPILogic,
|
||||
['makeRequest', 'apiSuccess', 'apiError'],
|
||||
],
|
||||
values: [FetchInferenceEndpointsAPILogic, ['data', 'status']],
|
||||
},
|
||||
listeners: ({ actions }) => ({
|
||||
fetchInferenceEndpoints: async (input, breakpoint) => {
|
||||
await breakpoint(150);
|
||||
actions.makeRequest(input);
|
||||
},
|
||||
}),
|
||||
path: ['enterprise_search', 'content', 'inference_endpoints_logic'],
|
||||
selectors: ({ selectors }) => ({
|
||||
inferenceEndpoints: [
|
||||
() => [selectors.data],
|
||||
(data) => (data?.inference_endpoints ? data.inference_endpoints : []),
|
||||
],
|
||||
}),
|
||||
});
|
|
@ -9,12 +9,14 @@ import { RouteDependencies } from '../../plugin';
|
|||
|
||||
import { registerDocumentRoute } from './documents';
|
||||
import { registerIndexRoutes } from './indices';
|
||||
import { registerInferenceEndpointRoutes } from './inference_endpoints';
|
||||
import { registerMappingRoute } from './mapping';
|
||||
import { registerSearchRoute } from './search';
|
||||
import { registerSearchApplicationsRoutes } from './search_applications';
|
||||
|
||||
export const registerEnterpriseSearchRoutes = (dependencies: RouteDependencies) => {
|
||||
registerIndexRoutes(dependencies);
|
||||
registerInferenceEndpointRoutes(dependencies);
|
||||
registerMappingRoute(dependencies);
|
||||
registerSearchRoute(dependencies);
|
||||
registerDocumentRoute(dependencies);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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 { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
|
||||
|
||||
import { RouteDependencies } from '../../plugin';
|
||||
import { elasticsearchErrorHandler } from '../../utils/elasticsearch_error_handler';
|
||||
|
||||
export function registerInferenceEndpointRoutes({ router, log }: RouteDependencies) {
|
||||
router.get(
|
||||
{
|
||||
path: '/internal/enterprise_search/inference_endpoints',
|
||||
validate: {},
|
||||
},
|
||||
elasticsearchErrorHandler(log, async (context, request, response) => {
|
||||
const { client } = (await context.core).elasticsearch;
|
||||
const { endpoints } = await client.asCurrentUser.transport.request<{
|
||||
endpoints: InferenceAPIConfigResponse[];
|
||||
}>({
|
||||
method: 'GET',
|
||||
path: `/_inference/_all`,
|
||||
});
|
||||
|
||||
return response.ok({
|
||||
body: {
|
||||
inference_endpoints: endpoints,
|
||||
},
|
||||
headers: { 'content-type': 'application/json' },
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue