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

[Inference Connector] Changed UI/UX due to the new RFC for the _inference/_service #203363

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -45152,7 +45152,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "Paramètres des tâches",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "Type de tâche",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "Configurer la tâche d'inférence. Ces paramètres sont spécifiques au service et au modèle sélectionnés.",
"xpack.stackConnectors.components.inference.taskTypeLabel": "Type de tâche",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "Impossible de trouver des fournisseurs",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "Token d'API",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45002,7 +45002,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "タスク設定",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "タスクタイプ",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "推論タスクを構成します。これらの設定は、選択したサービスおよびモデルに固有です。",
"xpack.stackConnectors.components.inference.taskTypeLabel": "タスクタイプ",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "プロバイダーが見つかりません",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "APIトークン",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44333,7 +44333,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "任务设置",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "任务类型",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "配置推理任务。这些设置特定于选定服务和模型。",
"xpack.stackConnectors.components.inference.taskTypeLabel": "任务类型",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "找不到提供商",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "API 令牌",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
23 changes: 3 additions & 20 deletions x-pack/plugins/stack_connectors/common/dynamic_config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
* 2.0.
*/

export enum DisplayType {
TEXTBOX = 'textbox',
TEXTAREA = 'textarea',
NUMERIC = 'numeric',
TOGGLE = 'toggle',
DROPDOWN = 'dropdown',
CHECKABLE = 'checkable',
}

export interface SelectOption {
label: string;
value: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is icon needed? I am importing SelectOption from search-connectors and icon is not defined there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, icon is needed to display it in the select if it present

Expand All @@ -28,7 +19,6 @@ export interface Dependency {
export enum FieldType {
STRING = 'str',
INTEGER = 'int',
LIST = 'list',
BOOLEAN = 'bool',
}

Expand All @@ -44,21 +34,13 @@ export interface Validation {
}

export interface ConfigProperties {
category?: string;
default_value: string | number | boolean | null;
depends_on: Dependency[];
display: DisplayType;
description: string | null;
label: string;
options?: SelectOption[];
order?: number | null;
placeholder?: string;
required: boolean;
sensitive: boolean;
tooltip: string | null;
updatable: boolean;
type: FieldType;
ui_restrictions: string[];
validations: Validation[];
value: string | number | boolean | null;
}

interface ConfigEntry extends ConfigProperties {
Expand All @@ -68,4 +50,5 @@ interface ConfigEntry extends ConfigProperties {
export interface ConfigEntryView extends ConfigEntry {
isValid: boolean;
validationErrors: string[];
value: string | number | boolean | null;
}
12 changes: 4 additions & 8 deletions x-pack/plugins/stack_connectors/common/inference/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ export type StreamingResponse = TypeOf<typeof StreamingResponseSchema>;

export type FieldsConfiguration = Record<string, ConfigProperties>;

export interface InferenceTaskType {
task_type: string;
configuration: FieldsConfiguration;
}

export interface InferenceProvider {
provider: string;
task_types: InferenceTaskType[];
service: string;
name: string;
task_types: string[];
logo?: string;
configuration: FieldsConfiguration;
configurations: FieldsConfiguration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useMemo, useCallback } from 'react';
import React, { useMemo } from 'react';
import { css } from '@emotion/react';

import {
Expand All @@ -18,7 +18,6 @@ import {
EuiTextColor,
EuiButtonGroup,
EuiPanel,
EuiHorizontalRule,
EuiButtonEmpty,
EuiCopy,
EuiButton,
Expand Down Expand Up @@ -55,7 +54,6 @@ interface AdditionalOptionsConnectorFieldsProps {
onTaskTypeOptionsSelect: (taskType: string, provider?: string) => void;
selectedTaskType?: string;
taskTypeFormFields: ConfigEntryView[];
taskTypeSchema: ConfigEntryView[];
taskTypeOptions: TaskTypeOption[];
}

Expand All @@ -65,35 +63,13 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
isEdit,
taskTypeOptions,
optionalProviderFormFields,
taskTypeFormFields,
taskTypeSchema,
selectedTaskType,
onSetProviderConfigEntry,
onTaskTypeOptionsSelect,
}) => {
const xsFontSize = useEuiFontSize('xs').fontSize;
const { euiTheme } = useEuiTheme();
const { setFieldValue, validateFields } = useFormContext();

const onSetTaskTypeConfigEntry = useCallback(
async (key: string, value: unknown) => {
if (taskTypeSchema) {
const entry: ConfigEntryView | undefined = taskTypeSchema.find(
(p: ConfigEntryView) => p.key === key
);
if (entry) {
if (!config.taskTypeConfig) {
config.taskTypeConfig = {};
}
const newConfig = { ...config.taskTypeConfig };
newConfig[key] = value;
setFieldValue('config.taskTypeConfig', newConfig);
await validateFields(['config.taskTypeConfig']);
}
}
},
[config, setFieldValue, taskTypeSchema, validateFields]
);
const { setFieldValue } = useFormContext();

const taskTypeSettings = useMemo(
() =>
Expand All @@ -103,7 +79,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
<h4>
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeDetailsLabel"
defaultMessage="Task settings"
defaultMessage="Task type"
/>
</h4>
</EuiTitle>
Expand All @@ -116,7 +92,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
>
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeHelpLabel"
defaultMessage="Configure the inference task. These settings are specific to the service and model selected."
defaultMessage="Configure the inference task. Task types are specific to the service and model selected."
/>
</div>
<EuiSpacer size="m" />
Expand All @@ -135,18 +111,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);

return (
<EuiFormRow
id="taskType"
fullWidth
label={
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeLabel"
defaultMessage="Task type"
/>
}
isInvalid={isInvalid}
error={errorMessage}
>
<EuiFormRow id="taskType" fullWidth isInvalid={isInvalid} error={errorMessage}>
{isEdit || readOnly ? (
<EuiButton
css={{
Expand Down Expand Up @@ -186,23 +151,13 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
);
}}
</UseField>
<EuiSpacer size="s" />
<ConnectorConfigurationFormItems
itemsGrow={false}
isLoading={false}
direction="column"
items={taskTypeFormFields}
setConfigEntry={onSetTaskTypeConfigEntry}
/>
</>
) : null,
[
selectedTaskType,
config?.taskType,
config.taskType,
xsFontSize,
euiTheme.colors,
taskTypeFormFields,
onSetTaskTypeConfigEntry,
isEdit,
readOnly,
taskTypeOptions,
Expand Down Expand Up @@ -276,7 +231,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
) : null}

{taskTypeSettings}
<EuiHorizontalRule />
<EuiSpacer size="m" />
<EuiTitle size="xxs" data-test-subj="task-type-details-label">
<h4>
<FormattedMessage
Expand Down
Loading
Loading