diff --git a/packages/kbn-text-based-editor/src/esql_documentation_sections.tsx b/packages/kbn-text-based-editor/src/esql_documentation_sections.tsx index 84dfcde890d66..24d621e0d3750 100644 --- a/packages/kbn-text-based-editor/src/esql_documentation_sections.tsx +++ b/packages/kbn-text-based-editor/src/esql_documentation_sections.tsx @@ -172,6 +172,7 @@ The \`SHOW \` source command returns information about the deployment and * Use \`SHOW INFO\` to return the deployment's version, build date and hash. * Use \`SHOW FUNCTIONS\` to return a list of all supported functions and a synopsis of each function. `, + ignoreTag: true, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', } @@ -214,9 +215,9 @@ Refer to the [dissect processor documentation](https://www.elastic.co/guide/en/e \`\`\` ROW a = "1953-01-23T12:15:00Z - some text - 127.0.0.1" -| DISSECT a "%\\{Y\\}-%\\{M\\}-%\\{D\\}T%\\{h\\}:%\\{m\\}:%\\{s\\}Z - %\\{msg\\} - %\\{ip\\}" -\`\`\` - `, +| DISSECT a "%'\{Y\}-%\{M\}-%\{D\}T%\{h\}:%\{m\}:%\{s\}Z - %\{msg\} - %\{ip\}'" +\`\`\` `, + ignoreTag: true, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', } @@ -308,6 +309,7 @@ By default (if no \`WITH\` is defined), \`ENRICH\` will add all the enrich field In case of name collisions, the newly created fields will override the existing fields. `, + ignoreTag: true, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', } @@ -376,7 +378,7 @@ Refer to the [grok processor documentation](https://www.elastic.co/guide/en/elas \`\`\` ROW a = "12 15.5 15.6 true" -| GROK a "%\\{NUMBER:b:int\\} %\\{NUMBER:c:float\\} %\\{NUMBER:d:double\\} %\\{WORD:e:boolean\\}" +| GROK a "%'{NUMBER:b:int}' %'{NUMBER:c:float}' %'{NUMBER:d:double}' %'{WORD:e:boolean}'" \`\`\` `, description: @@ -523,6 +525,7 @@ FROM employees | RENAME first_name AS fn, last_name AS ln \`\`\` `, + ignoreTag: true, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', } diff --git a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx index 52bda2fbda367..32ddf912bf740 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx +++ b/x-pack/plugins/observability_solution/logs_shared/public/components/logging/log_entry_flyout/log_entry_flyout.tsx @@ -209,6 +209,9 @@ export const LogEntryFlyout = ({ ); }; +// eslint-disable-next-line import/no-default-export +export default LogEntryFlyout; + const loadingProgressMessage = i18n.translate('xpack.logsShared.logFlyout.loadingMessage', { defaultMessage: 'Searching log entry in shards', }); diff --git a/x-pack/plugins/observability_solution/logs_shared/public/containers/logs/log_summary/with_summary.ts b/x-pack/plugins/observability_solution/logs_shared/public/containers/logs/log_summary/with_summary.ts index 5d18926cca294..bb8fe69d4356e 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/containers/logs/log_summary/with_summary.ts +++ b/x-pack/plugins/observability_solution/logs_shared/public/containers/logs/log_summary/with_summary.ts @@ -38,3 +38,6 @@ export const WithSummary = ({ serializedParsedQuery, children }: WithSummaryProp return children({ buckets, start, end }); }; + +// eslint-disable-next-line import/no-default-export +export default WithSummary; diff --git a/x-pack/plugins/observability_solution/logs_shared/public/index.ts b/x-pack/plugins/observability_solution/logs_shared/public/index.ts index 63b8a7d69834f..80b8dd3638924 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/index.ts +++ b/x-pack/plugins/observability_solution/logs_shared/public/index.ts @@ -33,8 +33,6 @@ export { useLogHighlightsStateContext, } from './containers/logs/log_highlights'; export type { LogSummaryBuckets, WithSummaryProps } from './containers/logs/log_summary'; -export { useLogSummary, WithSummary } from './containers/logs/log_summary'; -export { useLogEntryFlyout } from './components/logging/log_entry_flyout'; // Shared components export type { LogAIAssistantDocument } from './components/log_ai_assistant/log_ai_assistant'; @@ -46,10 +44,13 @@ export { iconColumnId, useColumnWidths, } from './components/logging/log_text_stream/log_entry_column'; -export { LogEntryFlyout } from './components/logging/log_entry_flyout'; export type { LogAIAssistantProps } from './components/log_ai_assistant/log_ai_assistant'; export type { LogStreamProps } from './components/log_stream/log_stream'; +export const WithSummary = dynamic(() => import('./containers/logs/log_summary/with_summary')); +export const LogEntryFlyout = dynamic( + () => import('./components/logging/log_entry_flyout/log_entry_flyout') +); export const LogAIAssistant = dynamic( () => import('./components/log_ai_assistant/log_ai_assistant') ); diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts index 58c93737b6617..8d509271c1e37 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts @@ -33,7 +33,7 @@ const getFunctionsRoute = createObservabilityAIAssistantServerRoute({ const client = await service.getClient({ request }); - const [functionClient, knowledgeBaseInstructions] = await Promise.all([ + const [functionClient, userInstructions] = await Promise.all([ service.getFunctionClient({ signal: controller.signal, resources, @@ -41,7 +41,7 @@ const getFunctionsRoute = createObservabilityAIAssistantServerRoute({ screenContexts: [], }), // error is caught in client - client.fetchKnowledgeBaseInstructions(), + client.fetchUserInstructions(), ]); const functionDefinitions = functionClient.getFunctions().map((fn) => fn.definition); @@ -52,7 +52,7 @@ const getFunctionsRoute = createObservabilityAIAssistantServerRoute({ functionDefinitions: functionClient.getFunctions().map((fn) => fn.definition), systemMessage: getSystemMessageFromInstructions({ registeredInstructions: functionClient.getInstructions(), - knowledgeBaseInstructions, + userInstructions, requestInstructions: [], availableFunctionNames, }), diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts index 829f0097875f8..4ffc8dc926fc7 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.test.ts @@ -112,7 +112,7 @@ describe('Observability AI Assistant client', () => { const knowledgeBaseServiceMock: DeeplyMockedKeys = { recall: jest.fn(), - getInstructions: jest.fn(), + getUserInstructions: jest.fn(), } as any; let loggerMock: DeeplyMockedKeys = {} as any; @@ -171,7 +171,7 @@ describe('Observability AI Assistant client', () => { fields: [], } as any); - knowledgeBaseServiceMock.getInstructions.mockResolvedValue([]); + knowledgeBaseServiceMock.getUserInstructions.mockResolvedValue([]); functionClientMock.getInstructions.mockReturnValue(['system']); diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.ts index 6af7ee9aa36ee..803e0e904223e 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/index.ts @@ -211,17 +211,17 @@ export class ObservabilityAIAssistantClient { ); } - const kbInstructions$ = from(this.fetchKnowledgeBaseInstructions()).pipe(shareReplay()); + const userInstructions$ = from(this.fetchUserInstructions()).pipe(shareReplay()); // from the initial messages, override any system message with // the one that is based on the instructions (registered, request, kb) - const messagesWithUpdatedSystemMessage$ = kbInstructions$.pipe( - map((knowledgeBaseInstructions) => { + const messagesWithUpdatedSystemMessage$ = userInstructions$.pipe( + map((userInstructions) => { // this is what we eventually store in the conversation const messagesWithUpdatedSystemMessage = replaceSystemMessage( getSystemMessageFromInstructions({ registeredInstructions: functionClient.getInstructions(), - knowledgeBaseInstructions, + userInstructions, requestInstructions, availableFunctionNames: functionClient .getFunctions() @@ -268,9 +268,9 @@ export class ObservabilityAIAssistantClient { // messages and the knowledge base instructions const nextEvents$ = combineLatest([ messagesWithUpdatedSystemMessage$, - kbInstructions$, + userInstructions$, ]).pipe( - switchMap(([messagesWithUpdatedSystemMessage, knowledgeBaseInstructions]) => { + switchMap(([messagesWithUpdatedSystemMessage, userInstructions]) => { // if needed, inject a context function request here const contextRequest = functionClient.hasFunction(CONTEXT_FUNCTION_NAME) ? getContextFunctionRequestIfNeeded(messagesWithUpdatedSystemMessage) @@ -298,7 +298,7 @@ export class ObservabilityAIAssistantClient { // start out with the max number of function calls functionCallsLeft: MAX_FUNCTION_CALLS, functionClient, - knowledgeBaseInstructions, + userInstructions, requestInstructions, signal, logger: this.dependencies.logger, @@ -756,12 +756,12 @@ export class ObservabilityAIAssistantClient { return this.dependencies.knowledgeBaseService.deleteEntry({ id }); }; - fetchKnowledgeBaseInstructions = async () => { - const knowledgeBaseInstructions = await this.dependencies.knowledgeBaseService.getInstructions( + fetchUserInstructions = async () => { + const userInstructions = await this.dependencies.knowledgeBaseService.getUserInstructions( this.dependencies.namespace, this.dependencies.user ); - return knowledgeBaseInstructions; + return userInstructions; }; } diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/operators/continue_conversation.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/operators/continue_conversation.ts index b7b134afc955c..2ab26cb4799ae 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/operators/continue_conversation.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/client/operators/continue_conversation.ts @@ -164,7 +164,7 @@ export function continueConversation({ signal, functionCallsLeft, requestInstructions, - knowledgeBaseInstructions, + userInstructions, logger, disableFunctions, tracer, @@ -175,7 +175,7 @@ export function continueConversation({ signal: AbortSignal; functionCallsLeft: number; requestInstructions: Array; - knowledgeBaseInstructions: UserInstruction[]; + userInstructions: UserInstruction[]; logger: Logger; disableFunctions: boolean; tracer: LangTracer; @@ -193,7 +193,7 @@ export function continueConversation({ const messagesWithUpdatedSystemMessage = replaceSystemMessage( getSystemMessageFromInstructions({ registeredInstructions: functionClient.getInstructions(), - knowledgeBaseInstructions, + userInstructions, requestInstructions, availableFunctionNames: definitions.map((def) => def.name), }), @@ -314,7 +314,7 @@ export function continueConversation({ functionCallsLeft: nextFunctionCallsLeft, functionClient, signal, - knowledgeBaseInstructions, + userInstructions, requestInstructions, logger, disableFunctions, diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/knowledge_base_service/index.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/knowledge_base_service/index.ts index 1f9ad5bc936f8..576fd8dc5552b 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/knowledge_base_service/index.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/knowledge_base_service/index.ts @@ -537,7 +537,7 @@ export class KnowledgeBaseService { }; }; - getInstructions = async ( + getUserInstructions = async ( namespace: string, user?: { name: string } ): Promise => { diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.test.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.test.ts index 9706871a63c62..99a2c34bc33d7 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.test.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.test.ts @@ -11,7 +11,7 @@ describe('getSystemMessageFromInstructions', () => { expect( getSystemMessageFromInstructions({ registeredInstructions: ['first', 'second'], - knowledgeBaseInstructions: [], + userInstructions: [], requestInstructions: [], availableFunctionNames: [], }) @@ -27,7 +27,7 @@ describe('getSystemMessageFromInstructions', () => { return availableFunctionNames[0]; }, ], - knowledgeBaseInstructions: [], + userInstructions: [], requestInstructions: [], availableFunctionNames: ['myFunction'], }) @@ -38,7 +38,7 @@ describe('getSystemMessageFromInstructions', () => { expect( getSystemMessageFromInstructions({ registeredInstructions: ['first'], - knowledgeBaseInstructions: [{ doc_id: 'second', text: 'second_kb' }], + userInstructions: [{ doc_id: 'second', text: 'second_kb' }], requestInstructions: [{ doc_id: 'second', text: 'second_request' }], availableFunctionNames: [], }) @@ -51,7 +51,7 @@ describe('getSystemMessageFromInstructions', () => { expect( getSystemMessageFromInstructions({ registeredInstructions: ['first'], - knowledgeBaseInstructions: [{ doc_id: 'second', text: 'second_kb' }], + userInstructions: [{ doc_id: 'second', text: 'second_kb' }], requestInstructions: [], availableFunctionNames: [], }) @@ -69,7 +69,7 @@ describe('getSystemMessageFromInstructions', () => { return undefined; }, ], - knowledgeBaseInstructions: [], + userInstructions: [], requestInstructions: [], availableFunctionNames: [], }) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.ts index 4ea5aaecb67f9..ece79b9f78485 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/service/util/get_system_message_from_instructions.ts @@ -13,12 +13,12 @@ import { RegisteredInstruction } from '../types'; export function getSystemMessageFromInstructions({ registeredInstructions, - knowledgeBaseInstructions, + userInstructions, requestInstructions, availableFunctionNames, }: { registeredInstructions: RegisteredInstruction[]; - knowledgeBaseInstructions: UserInstruction[]; + userInstructions: UserInstruction[]; requestInstructions: Array; availableFunctionNames: string[]; }): string { @@ -39,9 +39,7 @@ export function getSystemMessageFromInstructions({ // all request instructions, and those from the KB that are not defined as a request instruction const allUserInstructions = requestInstructionsWithId.concat( - knowledgeBaseInstructions.filter( - (instruction) => !requestOverrideIds.includes(instruction.doc_id) - ) + userInstructions.filter((instruction) => !requestOverrideIds.includes(instruction.doc_id)) ); const instructionsWithinBudget = withTokenBudget(allUserInstructions, 1000); diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts b/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts index c6b8b56b45a87..aac5637e7d5bb 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts @@ -224,7 +224,7 @@ async function executor( content: getSystemMessageFromInstructions({ availableFunctionNames: functionClient.getFunctions().map((fn) => fn.definition.name), registeredInstructions: functionClient.getInstructions(), - knowledgeBaseInstructions: [], + userInstructions: [], requestInstructions: [], }), },