Skip to content

Commit

Permalink
Remove inference_id field if no inference endpoint is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Samiul-TheSoccerFan committed Jan 6, 2025
1 parent 69cb966 commit 0361868
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@
"avcBanner.body": "Elastic Security passe avec brio le test de protection contre les malwares réalisé par AV-Comparatives",
"avcBanner.readTheBlog.link": "Lire le blog",
"avcBanner.title": "Protection à 100 % sans aucun faux positif.",
"bfetch.advancedSettings.disableBfetchCompressionDeprecation": "Ce paramètre est déclassé et sera supprimé dans la version 9.0 de Kibana.",
"bfetch.advancedSettings.disableBfetchDeprecation": "Ce paramètre est déclassé et sera supprimé dans la version 9.0 de Kibana.",
"bfetch.disableBfetch": "Désactiver la mise en lots de requêtes",
"bfetch.disableBfetchCompression": "Désactiver la compression par lots",
"bfetch.disableBfetchCompressionDesc": "Vous pouvez désactiver la compression par lots. Cela permet de déboguer des requêtes individuelles, mais augmente la taille des réponses.",
"bfetch.disableBfetchDesc": "Désactive la mise en lot des requêtes. Cette option augmente le nombre de requêtes HTTP depuis Kibana, mais permet de les déboguer individuellement.",
"bfetchError.networkError": "Vérifiez votre connexion réseau et réessayez.",
"bfetchError.networkErrorWithStatus": "Vérifiez votre connexion réseau et réessayez. Code {code}",
"cases.components.status.closed": "Fermé",
"cases.components.status.inProgress": "En cours",
"cases.components.status.open": "Ouvrir",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@
"avcBanner.body": "AV-Comparativesのマルウェア保護テストで高い評価を受けたElastic Security",
"avcBanner.readTheBlog.link": "ブログを読む",
"avcBanner.title": "誤検知がゼロの100%保護。",
"bfetch.advancedSettings.disableBfetchCompressionDeprecation": "この設定はサポートが終了し、Kibana 9.0では削除されます。",
"bfetch.advancedSettings.disableBfetchDeprecation": "この設定はサポートが終了し、Kibana 9.0では削除されます。",
"bfetch.disableBfetch": "リクエストバッチを無効にする",
"bfetch.disableBfetchCompression": "バッチ圧縮を無効にする",
"bfetch.disableBfetchCompressionDesc": "バッチ圧縮を無効にします。個別の要求をデバッグできますが、応答サイズが大きくなります。",
"bfetch.disableBfetchDesc": "リクエストバッチを無効にします。これにより、KibanaからのHTTPリクエスト数は減りますが、個別にリクエストをデバッグできます。",
"bfetchError.networkError": "ネットワーク接続を確認して再試行してください。",
"bfetchError.networkErrorWithStatus": "ネットワーク接続を確認して再試行してください。コード{code}",
"cases.components.status.closed": "終了",
"cases.components.status.inProgress": "進行中",
"cases.components.status.open": "オープン",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,6 @@
"avcBanner.body": "在 AV-Comparatives 进行的恶意软件防护测试中,Elastic Security 表现突出",
"avcBanner.readTheBlog.link": "阅读博客",
"avcBanner.title": "提供全面保护,误报率为零。",
"bfetch.advancedSettings.disableBfetchCompressionDeprecation": "此设置已过时,将在 Kibana 9.0 中移除。",
"bfetch.advancedSettings.disableBfetchDeprecation": "此设置已过时,将在 Kibana 9.0 中移除。",
"bfetch.disableBfetch": "禁用请求批处理",
"bfetch.disableBfetchCompression": "禁用批量压缩",
"bfetch.disableBfetchCompressionDesc": "禁用批量压缩。这允许您对单个请求进行故障排查,但会增加响应大小。",
"bfetch.disableBfetchDesc": "禁用请求批处理。这会增加来自 Kibana 的 HTTP 请求数,但允许对单个请求进行故障排查。",
"bfetchError.networkError": "检查您的网络连接,然后重试。",
"bfetchError.networkErrorWithStatus": "检查您的网络连接,然后重试。代码 {code}",
"cases.components.status.closed": "已关闭",
"cases.components.status.inProgress": "进行中",
"cases.components.status.open": "打开",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TrainedModelStat } from '@kbn/ml-plugin/common/types/trained_models';
import { MlPluginStart } from '@kbn/ml-plugin/public';
import classNames from 'classnames';
import React, { useEffect, useRef } from 'react';
import { isEmpty } from 'lodash';
import { EUI_SIZE, TYPE_DEFINITION } from '../../../../constants';
import { fieldSerializer } from '../../../../lib';
import { isSemanticTextField } from '../../../../lib/utils';
Expand Down Expand Up @@ -106,7 +107,7 @@ export const CreateField = React.memo(function CreateFieldComponent({
}
};

const { createInferenceEndpoint, handleSemanticText } = useSemanticText({
const { createInferenceEndpoint } = useSemanticText({
form,
setErrorsInTrainedModelDeployment,
ml,
Expand All @@ -130,8 +131,9 @@ export const CreateField = React.memo(function CreateFieldComponent({
const { isValid, data } = await form.submit();

if (isValid && !clickOutside) {
if (isSemanticTextField(data)) {
handleSemanticText(data);
if (isSemanticTextField(data) && isEmpty(data.inference_id)) {
const { inference_id: inferenceId, ...rest } = data;
dispatch({ type: 'field.add', value: rest });
} else {
dispatch({ type: 'field.add', value: data });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ function FieldListItemComponent(
</EuiBadge>
</EuiFlexItem>

{isSemanticText && (
{isSemanticText && source.inference_id ? (
<EuiFlexItem grow={false}>
<EuiBadge color="hollow">{source.inference_id as string}</EuiBadge>
</EuiFlexItem>
)}
) : null}

{isShadowed && (
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export const getAllFieldTypesFromState = (allFields: Fields): DataType[] => {
};

export function isSemanticTextField(field: Partial<Field>): field is SemanticTextField {
return Boolean(field.inference_id && field.type === 'semantic_text');
return field.type === 'semantic_text';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import React, { FunctionComponent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { ILicense } from '@kbn/licensing-plugin/public';
import { useUnsavedChangesPrompt } from '@kbn/unsaved-changes-prompt';
import { isEmpty } from 'lodash';
import {
getStateWithCopyToFields,
isSemanticTextField,
Expand Down Expand Up @@ -237,6 +238,7 @@ export const DetailsPageMappingsContent: FunctionComponent<{
.map((field) => field.inference_id)
.filter(
(inferenceId: string) =>
!isEmpty(inferenceId) &&
inferenceToModelIdMap?.[inferenceId].trainedModelId && // third-party inference models don't have trainedModelId
!inferenceToModelIdMap?.[inferenceId].isDeployed &&
!isInferencePreconfigured(inferenceId)
Expand Down

0 comments on commit 0361868

Please sign in to comment.