Skip to content

Commit a47f4c4

Browse files
ensure values show correctly on edit
1 parent 2c9edf2 commit a47f4c4

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

x-pack/platform/packages/shared/kbn-inference-endpoint-ui-common/src/components/inference_flyout_wrapper.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,33 @@ import type { InferenceEndpoint } from '../types/types';
2727
import { InferenceServiceFormFields } from './inference_service_form_fields';
2828
import { useInferenceEndpointMutation } from '../hooks/use_inference_endpoint_mutation';
2929

30+
const formDeserializer = (data: InferenceEndpoint) => {
31+
if (
32+
data?.config?.providerConfig &&
33+
data?.config?.providerConfig['adaptive_allocations.max_number_of_allocations']
34+
) {
35+
// remove num_allocations and num_threads from the data as form does not expect it
36+
const {
37+
num_allocations: numAllocations,
38+
num_threads: numThreads,
39+
...restOfProviderConfig
40+
} = data.config.providerConfig;
41+
return {
42+
...data,
43+
config: {
44+
...data.config,
45+
providerConfig: {
46+
...restOfProviderConfig,
47+
max_number_of_allocations:
48+
restOfProviderConfig['adaptive_allocations.max_number_of_allocations'],
49+
},
50+
},
51+
};
52+
}
53+
54+
return data;
55+
};
56+
3057
interface InferenceFlyoutWrapperProps {
3158
onFlyoutClose: () => void;
3259
http: HttpSetup;
@@ -70,6 +97,7 @@ export const InferenceFlyoutWrapper: React.FC<InferenceFlyoutWrapperProps> = ({
7097
providerSecrets: {},
7198
},
7299
},
100+
deserializer: formDeserializer,
73101
});
74102
const handleSubmit = useCallback(async () => {
75103
const { isValid, data } = await form.submit();

x-pack/platform/packages/shared/kbn-inference-endpoint-ui-common/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const INTERNAL_OVERRIDE_FIELDS: InternalOverrideFieldsType = {
5959
sensitive: false,
6060
supported_task_types: ['text_embedding', 'sparse_embedding', 'rerank'],
6161
type: FieldType.INTEGER,
62-
updatable: true,
62+
updatable: false,
6363
},
6464
},
6565
],

x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/action_connector_form/connector_form.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ interface Props {
4848
onFormModifiedChange?: (isModified: boolean) => void;
4949
setResetForm?: (value: ResetForm) => void;
5050
}
51+
52+
interface ProviderConfig {
53+
[key: string]: unknown;
54+
adaptive_allocations?: { max_number_of_allocations?: number };
55+
}
5156
/**
5257
* The serializer and deserializer are needed to transform the headers of
5358
* the webhook connectors. The webhook connector uses the UseArray component
@@ -62,6 +67,27 @@ interface Props {
6267

6368
// TODO: Remove when https://github.com/elastic/kibana/issues/133107 is resolved
6469
const formDeserializer = (data: ConnectorFormSchema): ConnectorFormSchema => {
70+
if (
71+
data.actionTypeId === '.inference' &&
72+
// explicit check to see if this field exists
73+
(data?.config?.providerConfig as ProviderConfig)?.adaptive_allocations
74+
?.max_number_of_allocations
75+
) {
76+
return {
77+
...data,
78+
config: {
79+
...data.config,
80+
providerConfig: {
81+
...(data.config.providerConfig as ProviderConfig),
82+
max_number_of_allocations: (data.config.providerConfig as ProviderConfig)
83+
.adaptive_allocations?.max_number_of_allocations,
84+
// remove the adaptive_allocations from the data config as form does not expect it
85+
adaptive_allocations: undefined,
86+
},
87+
},
88+
};
89+
}
90+
6591
if (
6692
data.actionTypeId !== '.webhook' &&
6793
data.actionTypeId !== '.cases-webhook' &&

0 commit comments

Comments
 (0)