From 9b158e2295d18e3e04f52c3af97f6ce0bf8c1282 Mon Sep 17 00:00:00 2001 From: Kenneth Kreindler Date: Mon, 10 Feb 2025 14:30:33 +0000 Subject: [PATCH 1/8] Update copy for citations tour + disable citations when they are unavailable --- .../impl/assistant/assistant_header/index.tsx | 2 +- .../assistant_header/translations.ts | 19 --- .../conversations/utils/index.test.ts | 25 ++++ .../assistant/conversations/utils/index.ts | 10 ++ .../impl/assistant/index.tsx | 4 + .../settings_context_menu.tsx | 128 ++++++++++++++---- .../index.tsx | 11 +- .../step_config.tsx | 8 +- 8 files changed, 149 insertions(+), 58 deletions(-) create mode 100644 x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts create mode 100644 x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx index 95085ac8ef8d6..057dd1031e4cd 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx @@ -174,7 +174,7 @@ export const AssistantHeader: React.FC = ({ /> - + diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/translations.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/translations.ts index d38eb73b28939..38d439848ee38 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/translations.ts +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/translations.ts @@ -84,25 +84,6 @@ export const CHAT_OPTIONS = i18n.translate( } ); -const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0; - -export const ANONYMIZE_VALUES_TOOLTIP = i18n.translate( - 'xpack.elasticAssistant.assistant.settings.anonymizeValues.tooltip', - { - values: { keyboardShortcut: isMac ? '⌥ + a' : 'Alt + a' }, - defaultMessage: - 'Toggle to reveal or hide field values in your chat stream. The data sent to the LLM is still anonymized based on settings in the Anonymization panel. Keyboard shortcut: {keyboardShortcut}', - } -); - -export const SHOW_CITATIONS_TOOLTIP = i18n.translate( - 'xpack.elasticAssistant.assistant.settings.showCitationsLabel.tooltip', - { - values: { keyboardShortcut: isMac ? '⌥ + c' : 'Alt + c' }, - defaultMessage: 'Keyboard shortcut: {keyboardShortcut}', - } -); - export const CANCEL_BUTTON_TEXT = i18n.translate( 'xpack.elasticAssistant.assistant.resetConversationModal.cancelButtonText', { diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts new file mode 100644 index 0000000000000..066db3ce6b489 --- /dev/null +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts @@ -0,0 +1,25 @@ +import { alertConvo, conversationWithContentReferences } from '@kbn/elastic-assistant/impl/mock/conversation'; +import { Conversation } from '../../../..'; +import { conversationContainsContentReferences, conversationContainsAnonymizedValues } from '.'; + + +describe('conversation utils', () => { + + it.each([ + [undefined, false], + [conversationWithContentReferences, true], + [alertConvo, false], + ])('conversationContainsContentReferences', (conversation: Conversation|undefined, expected: boolean) => { + expect(conversationContainsContentReferences(conversation)).toBe(expected); + }) + + it.each([ + [undefined, false], + [conversationWithContentReferences, false], + [alertConvo, true], + ])('conversationContainsAnonymizedValues', (conversation: Conversation|undefined, expected: boolean) => { + expect(conversationContainsAnonymizedValues(conversation)).toBe(expected); + }) + +}); + \ No newline at end of file diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts new file mode 100644 index 0000000000000..e10ecbf680d93 --- /dev/null +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts @@ -0,0 +1,10 @@ +import { isEmpty } from 'lodash'; +import { Conversation } from '../../../..'; + +export const conversationContainsContentReferences = (conversation?: Conversation): boolean => { + return conversation?.messages.some(message => !isEmpty(message.metadata?.contentReferences)) ?? false +} + +export const conversationContainsAnonymizedValues = (conversation?: Conversation): boolean => { + return !isEmpty(conversation?.replacements) +} \ No newline at end of file diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx index 399739099109c..1ce50fe31ab0c 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx @@ -51,6 +51,7 @@ import { ConversationSidePanel } from './conversations/conversation_sidepanel'; import { SelectedPromptContexts } from './prompt_editor/selected_prompt_contexts'; import { AssistantHeader } from './assistant_header'; import { AnonymizedValuesAndCitationsTour } from '../tour/anonymized_values_and_citations_tour'; +import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from './conversations/utils'; export const CONVERSATION_SIDE_PANEL_WIDTH = 220; @@ -227,10 +228,12 @@ const AssistantComponent: React.FC = ({ const onKeyDown = useCallback( (event: KeyboardEvent) => { if (event.altKey && event.code === 'KeyC') { + if(!conversationContainsContentReferences(currentConversation)) return event.preventDefault(); setContentReferencesVisible(!contentReferencesVisible); } if (event.altKey && event.code === 'KeyA') { + if(!conversationContainsAnonymizedValues(currentConversation)) return event.preventDefault(); setShowAnonymizedValues(!showAnonymizedValues); } @@ -240,6 +243,7 @@ const AssistantComponent: React.FC = ({ contentReferencesVisible, setShowAnonymizedValues, showAnonymizedValues, + currentConversation ] ); diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx index 075b6980a45ab..55f6df398cffa 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx @@ -22,23 +22,33 @@ import { EuiHorizontalRule, EuiToolTip, EuiSwitchEvent, + EuiIcon, } from '@elastic/eui'; import { css } from '@emotion/react'; import { KnowledgeBaseTour } from '../../../tour/knowledge_base'; import { AnonymizationSettingsManagement } from '../../../data_anonymization/settings/anonymization_settings_management'; -import { useAssistantContext } from '../../../..'; +import { Conversation, useAssistantContext } from '../../../..'; import * as i18n from '../../assistant_header/translations'; import { AlertsSettingsModal } from '../alerts_settings/alerts_settings_modal'; import { KNOWLEDGE_BASE_TAB } from '../const'; import { AI_ASSISTANT_MENU } from './translations'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from '../../conversations/utils'; interface Params { isDisabled?: boolean; onChatCleared?: () => void; + selectedConversation?: Conversation; } +const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0; + +const ConditionalWrap = ({ condition, wrap, children }: { condition: boolean, wrap: (children: React.ReactElement) => React.ReactElement, children: React.ReactElement }) => ( + condition ? wrap(children) : children +); + export const SettingsContextMenu: React.FC = React.memo( - ({ isDisabled = false, onChatCleared }: Params) => { + ({ isDisabled = false, onChatCleared, selectedConversation }: Params) => { const { euiTheme } = useEuiTheme(); const { navigateToApp, @@ -117,6 +127,13 @@ export const SettingsContextMenu: React.FC = React.memo( [setShowAnonymizedValues] ); + const selectedConversationHasCitations = useMemo( + () => conversationContainsContentReferences(selectedConversation), + [selectedConversation] + ); + + const selectedConversationHasAnonymizedValues = useMemo(() => conversationContainsAnonymizedValues(selectedConversation), [selectedConversation]); + const items = useMemo( () => [ = React.memo(

{i18n.CHAT_OPTIONS}

- - - - + + + ( + } + > + {children} + + )}> + + + + + {str}, + }} + />} + > + + + + +
+ {contentReferencesEnabled && ( - - - - + + + (} + >{children})}> + + + + + {str}, + }} + />} + > + + + + + )} = React.memo( contentReferencesEnabled, euiTheme.size.m, euiTheme.size.xs, + selectedConversationHasCitations, + selectedConversationHasAnonymizedValues, ] ); diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx index da2bbc7469b46..d28dc480be440 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx @@ -7,12 +7,13 @@ import { EuiTourStep } from '@elastic/eui'; import React, { useCallback, useEffect, useState } from 'react'; -import { isEmpty, throttle } from 'lodash'; +import { throttle } from 'lodash'; import useLocalStorage from 'react-use/lib/useLocalStorage'; import { Conversation } from '../../assistant_context/types'; import { NEW_FEATURES_TOUR_STORAGE_KEYS } from '../const'; import { anonymizedValuesAndCitationsTourStep1 } from './step_config'; import { TourState } from '../knowledge_base'; +import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from '../../assistant/conversations/utils'; interface Props { conversation: Conversation | undefined; @@ -49,12 +50,10 @@ export const AnonymizedValuesAndCitationsTour: React.FC = ({ conversation return; } - const containsContentReferences = conversation.messages.some( - (message) => !isEmpty(message.metadata?.contentReferences) - ); - const containsReplacements = !isEmpty(conversation.replacements); + const containsContentReferences = conversationContainsContentReferences(conversation); + const containsAnonymizedValues = conversationContainsAnonymizedValues(conversation); - if (containsContentReferences || containsReplacements) { + if (containsContentReferences || containsAnonymizedValues) { const timer = setTimeout(() => { setShowTour(true); }, 1000); diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx index dad5326f0be2c..d2eea63d6f1bd 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx @@ -30,18 +30,18 @@ export const anonymizedValuesAndCitationsTourStep1 = { {str}, }} /> {str}, }} /> From cdd61933a3b82ed36af2e061bf6b08dec0443251 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:45:22 +0000 Subject: [PATCH 2/8] [CI] Auto-commit changed files from 'node scripts/notice' --- .../platform/packages/shared/kbn-elastic-assistant/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json b/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json index a0c9dee5da6b6..2c3e68732b206 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json @@ -42,5 +42,6 @@ "@kbn/spaces-plugin", "@kbn/shared-ux-router", "@kbn/inference-endpoint-ui-common", + "@kbn/elastic-assistant", ] } From ab98a98c4009f629d828acd63c4ecbbf949747d7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:01:24 +0000 Subject: [PATCH 3/8] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../impl/assistant/assistant_header/index.tsx | 6 +- .../conversations/utils/index.test.ts | 47 +++--- .../assistant/conversations/utils/index.ts | 17 ++- .../impl/assistant/index.tsx | 11 +- .../settings_context_menu.tsx | 138 +++++++++++------- .../index.tsx | 5 +- 6 files changed, 141 insertions(+), 83 deletions(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx index 057dd1031e4cd..1134b79fa09b5 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/assistant_header/index.tsx @@ -174,7 +174,11 @@ export const AssistantHeader: React.FC = ({ /> - + diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts index 066db3ce6b489..2b4c0270c3ace 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.test.ts @@ -1,25 +1,34 @@ -import { alertConvo, conversationWithContentReferences } from '@kbn/elastic-assistant/impl/mock/conversation'; +/* + * 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 { alertConvo, conversationWithContentReferences } from '../../../mock/conversation'; import { Conversation } from '../../../..'; import { conversationContainsContentReferences, conversationContainsAnonymizedValues } from '.'; - describe('conversation utils', () => { - - it.each([ - [undefined, false], - [conversationWithContentReferences, true], - [alertConvo, false], - ])('conversationContainsContentReferences', (conversation: Conversation|undefined, expected: boolean) => { - expect(conversationContainsContentReferences(conversation)).toBe(expected); - }) - - it.each([ - [undefined, false], - [conversationWithContentReferences, false], - [alertConvo, true], - ])('conversationContainsAnonymizedValues', (conversation: Conversation|undefined, expected: boolean) => { - expect(conversationContainsAnonymizedValues(conversation)).toBe(expected); - }) + it.each([ + [undefined, false], + [conversationWithContentReferences, true], + [alertConvo, false], + ])( + 'conversationContainsContentReferences', + (conversation: Conversation | undefined, expected: boolean) => { + expect(conversationContainsContentReferences(conversation)).toBe(expected); + } + ); + it.each([ + [undefined, false], + [conversationWithContentReferences, false], + [alertConvo, true], + ])( + 'conversationContainsAnonymizedValues', + (conversation: Conversation | undefined, expected: boolean) => { + expect(conversationContainsAnonymizedValues(conversation)).toBe(expected); + } + ); }); - \ No newline at end of file diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts index e10ecbf680d93..5f057d4dcf76b 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts @@ -1,10 +1,19 @@ +/* + * 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 { isEmpty } from 'lodash'; import { Conversation } from '../../../..'; export const conversationContainsContentReferences = (conversation?: Conversation): boolean => { - return conversation?.messages.some(message => !isEmpty(message.metadata?.contentReferences)) ?? false -} + return ( + conversation?.messages.some((message) => !isEmpty(message.metadata?.contentReferences)) ?? false + ); +}; export const conversationContainsAnonymizedValues = (conversation?: Conversation): boolean => { - return !isEmpty(conversation?.replacements) -} \ No newline at end of file + return !isEmpty(conversation?.replacements); +}; diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx index 1ce50fe31ab0c..82765fac41e15 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/index.tsx @@ -51,7 +51,10 @@ import { ConversationSidePanel } from './conversations/conversation_sidepanel'; import { SelectedPromptContexts } from './prompt_editor/selected_prompt_contexts'; import { AssistantHeader } from './assistant_header'; import { AnonymizedValuesAndCitationsTour } from '../tour/anonymized_values_and_citations_tour'; -import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from './conversations/utils'; +import { + conversationContainsAnonymizedValues, + conversationContainsContentReferences, +} from './conversations/utils'; export const CONVERSATION_SIDE_PANEL_WIDTH = 220; @@ -228,12 +231,12 @@ const AssistantComponent: React.FC = ({ const onKeyDown = useCallback( (event: KeyboardEvent) => { if (event.altKey && event.code === 'KeyC') { - if(!conversationContainsContentReferences(currentConversation)) return + if (!conversationContainsContentReferences(currentConversation)) return; event.preventDefault(); setContentReferencesVisible(!contentReferencesVisible); } if (event.altKey && event.code === 'KeyA') { - if(!conversationContainsAnonymizedValues(currentConversation)) return + if (!conversationContainsAnonymizedValues(currentConversation)) return; event.preventDefault(); setShowAnonymizedValues(!showAnonymizedValues); } @@ -243,7 +246,7 @@ const AssistantComponent: React.FC = ({ contentReferencesVisible, setShowAnonymizedValues, showAnonymizedValues, - currentConversation + currentConversation, ] ); diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx index 55f6df398cffa..c3760106514c9 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/settings_context_menu/settings_context_menu.tsx @@ -25,6 +25,7 @@ import { EuiIcon, } from '@elastic/eui'; import { css } from '@emotion/react'; +import { FormattedMessage } from '@kbn/i18n-react'; import { KnowledgeBaseTour } from '../../../tour/knowledge_base'; import { AnonymizationSettingsManagement } from '../../../data_anonymization/settings/anonymization_settings_management'; import { Conversation, useAssistantContext } from '../../../..'; @@ -32,8 +33,10 @@ import * as i18n from '../../assistant_header/translations'; import { AlertsSettingsModal } from '../alerts_settings/alerts_settings_modal'; import { KNOWLEDGE_BASE_TAB } from '../const'; import { AI_ASSISTANT_MENU } from './translations'; -import { FormattedMessage } from '@kbn/i18n-react'; -import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from '../../conversations/utils'; +import { + conversationContainsAnonymizedValues, + conversationContainsContentReferences, +} from '../../conversations/utils'; interface Params { isDisabled?: boolean; @@ -43,9 +46,15 @@ interface Params { const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0; -const ConditionalWrap = ({ condition, wrap, children }: { condition: boolean, wrap: (children: React.ReactElement) => React.ReactElement, children: React.ReactElement }) => ( - condition ? wrap(children) : children -); +const ConditionalWrap = ({ + condition, + wrap, + children, +}: { + condition: boolean; + wrap: (children: React.ReactElement) => React.ReactElement; + children: React.ReactElement; +}) => (condition ? wrap(children) : children); export const SettingsContextMenu: React.FC = React.memo( ({ isDisabled = false, onChatCleared, selectedConversation }: Params) => { @@ -132,7 +141,10 @@ export const SettingsContextMenu: React.FC = React.memo( [selectedConversation] ); - const selectedConversationHasAnonymizedValues = useMemo(() => conversationContainsAnonymizedValues(selectedConversation), [selectedConversation]); + const selectedConversationHasAnonymizedValues = useMemo( + () => conversationContainsAnonymizedValues(selectedConversation), + [selectedConversation] + ); const items = useMemo( () => [ @@ -191,25 +203,30 @@ export const SettingsContextMenu: React.FC = React.memo(

{i18n.CHAT_OPTIONS}

- - + + - ( - } - > - {children} - - )}> + ( + + } + > + {children} + + )} + > = React.memo( {str}, - }} - />} + content={ + {str}, + }} + /> + } > @@ -239,21 +258,30 @@ export const SettingsContextMenu: React.FC = React.memo( {contentReferencesEnabled && ( - - + + - (} - >{children})}> + ( + + } + > + {children} + + )} + > = React.memo( {str}, - }} - />} + content={ + {str}, + }} + /> + } > diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx index d28dc480be440..83b718d999768 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/index.tsx @@ -13,7 +13,10 @@ import { Conversation } from '../../assistant_context/types'; import { NEW_FEATURES_TOUR_STORAGE_KEYS } from '../const'; import { anonymizedValuesAndCitationsTourStep1 } from './step_config'; import { TourState } from '../knowledge_base'; -import { conversationContainsAnonymizedValues, conversationContainsContentReferences } from '../../assistant/conversations/utils'; +import { + conversationContainsAnonymizedValues, + conversationContainsContentReferences, +} from '../../assistant/conversations/utils'; interface Props { conversation: Conversation | undefined; From 100212892924f963400e3a9a933e314a87c30ca6 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:23:48 +0000 Subject: [PATCH 4/8] [CI] Auto-commit changed files from 'node scripts/notice' --- .../platform/packages/shared/kbn-elastic-assistant/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json b/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json index 2c3e68732b206..a0c9dee5da6b6 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/tsconfig.json @@ -42,6 +42,5 @@ "@kbn/spaces-plugin", "@kbn/shared-ux-router", "@kbn/inference-endpoint-ui-common", - "@kbn/elastic-assistant", ] } From beddb3f0c65c44b9f0a73cb8aeb6c3da09680c98 Mon Sep 17 00:00:00 2001 From: Kenneth Kreindler Date: Mon, 10 Feb 2025 16:03:22 +0000 Subject: [PATCH 5/8] Add comment --- .../impl/assistant/conversations/utils/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts index e10ecbf680d93..816f0be293991 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/conversations/utils/index.ts @@ -5,6 +5,7 @@ export const conversationContainsContentReferences = (conversation?: Conversatio return conversation?.messages.some(message => !isEmpty(message.metadata?.contentReferences)) ?? false } +/** Checks if the conversations has replacements, not if the replacements are actually used */ export const conversationContainsAnonymizedValues = (conversation?: Conversation): boolean => { return !isEmpty(conversation?.replacements) } \ No newline at end of file From 843368f095d8c1550fc7b9ffeba83d5befc2194b Mon Sep 17 00:00:00 2001 From: Kenneth Kreindler Date: Thu, 20 Feb 2025 09:17:25 +0000 Subject: [PATCH 6/8] fix copy --- .../tour/anonymized_values_and_citations_tour/step_config.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx index d2eea63d6f1bd..7ba56b8db8cdc 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/tour/anonymized_values_and_citations_tour/step_config.tsx @@ -30,7 +30,7 @@ export const anonymizedValuesAndCitationsTourStep1 = { {str}, From da377dac0e1e16bdd36231b86fb1f34b66540e3f Mon Sep 17 00:00:00 2001 From: Kenneth Kreindler Date: Thu, 20 Feb 2025 10:40:33 +0000 Subject: [PATCH 7/8] handle metadata for regenerated messages --- .../kbn-elastic-assistant/impl/assistant/api/index.tsx | 5 ++++- .../shared/kbn-elastic-assistant/impl/assistant/helpers.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx index f84c525e2d989..5fc905bd5c693 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx @@ -6,7 +6,7 @@ */ import { HttpSetup } from '@kbn/core/public'; -import { API_VERSIONS, ApiConfig, Replacements } from '@kbn/elastic-assistant-common'; +import { API_VERSIONS, ApiConfig, MessageMetadata, Replacements } from '@kbn/elastic-assistant-common'; import { API_ERROR } from '../translations'; import { getOptionalRequestParams } from '../helpers'; import { TraceOptions } from '../types'; @@ -34,6 +34,7 @@ export interface FetchConnectorExecuteResponse { transactionId: string; traceId: string; }; + metadata?: MessageMetadata; } export const fetchConnectorExecuteAction = async ({ @@ -110,6 +111,7 @@ export const fetchConnectorExecuteAction = async ({ transaction_id: string; trace_id: string; }; + metadata?: MessageMetadata }>(`/internal/elastic_assistant/actions/connector/${apiConfig?.connectorId}/_execute`, { method: 'POST', body: JSON.stringify(requestBody), @@ -144,6 +146,7 @@ export const fetchConnectorExecuteAction = async ({ return { response: response.data, + metadata: response.metadata, isError: false, isStream: false, traceData, diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/helpers.ts b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/helpers.ts index 9265cdd9d57ec..7c4aa0482c052 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/helpers.ts +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/helpers.ts @@ -25,6 +25,7 @@ export const getMessageFromRawResponse = ( timestamp: dateTimeString, isError, traceData: rawResponse.traceData, + metadata: rawResponse.metadata, }; } else { return { From 8128055cb486774d566c9108851f652522eaa60b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 20 Feb 2025 11:37:17 +0000 Subject: [PATCH 8/8] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../kbn-elastic-assistant/impl/assistant/api/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx index 5fc905bd5c693..88c5727ee0963 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/api/index.tsx @@ -6,7 +6,12 @@ */ import { HttpSetup } from '@kbn/core/public'; -import { API_VERSIONS, ApiConfig, MessageMetadata, Replacements } from '@kbn/elastic-assistant-common'; +import { + API_VERSIONS, + ApiConfig, + MessageMetadata, + Replacements, +} from '@kbn/elastic-assistant-common'; import { API_ERROR } from '../translations'; import { getOptionalRequestParams } from '../helpers'; import { TraceOptions } from '../types'; @@ -111,7 +116,7 @@ export const fetchConnectorExecuteAction = async ({ transaction_id: string; trace_id: string; }; - metadata?: MessageMetadata + metadata?: MessageMetadata; }>(`/internal/elastic_assistant/actions/connector/${apiConfig?.connectorId}/_execute`, { method: 'POST', body: JSON.stringify(requestBody),