From 7b69cfd48f800dafcdaf1d2c2c2b6e2beb33e8c7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 24 Feb 2025 11:20:36 +0000 Subject: [PATCH] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../impl/assistant/index.tsx | 3 +- .../settings_context_menu.tsx | 104 +++++++++--------- .../server/ai_assistant_service/index.ts | 4 +- .../graphs/default_assistant_graph/index.ts | 2 +- .../server/routes/evaluate/post_evaluate.ts | 2 +- .../server/routes/helpers.ts | 2 +- .../routes/post_actions_connector_execute.ts | 2 +- .../routes/user_conversations/find_route.ts | 2 +- .../tools/alert_counts/alert_counts_tool.ts | 4 +- .../knowledge_base_retrieval_tool.ts | 3 +- .../open_and_acknowledged_alerts_tool.ts | 6 +- .../product_documentation_tool.ts | 15 +-- .../tools/security_labs/security_labs_tool.ts | 6 +- 13 files changed, 77 insertions(+), 78 deletions(-) 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 3946ce917620c..a936eae8ddafa 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 @@ -454,8 +454,7 @@ const AssistantComponent: React.FC = ({ return ( <> - - + {chatHistoryVisible && ( = React.memo( - - - - ( - - } - > - {children} - - )} - > - + + + ( + + } + > + {children} + + )} + > + + + + + {str}, + }} /> - - - - {str}, - }} - /> - } - > - - - - - + } + > + + + + + = async ({ abortSignal, diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/evaluate/post_evaluate.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/evaluate/post_evaluate.ts index dc1fe194b8313..226b7602b9d76 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/evaluate/post_evaluate.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/evaluate/post_evaluate.ts @@ -290,7 +290,7 @@ export const postEvaluateRoute = ( }, }; - const contentReferencesStore = newContentReferencesStore() + const contentReferencesStore = newContentReferencesStore(); // Fetch any applicable tools that the source plugin may have registered const assistantToolParams: AssistantToolParams = { diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/helpers.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/helpers.ts index c2a4d94ee9b9f..346d17eb7bdfc 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/helpers.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/helpers.ts @@ -34,6 +34,7 @@ import { AssistantFeatureKey } from '@kbn/elastic-assistant-common/impl/capabili import { getLangSmithTracer } from '@kbn/langchain/server/tracers/langsmith'; import type { InferenceServerStart } from '@kbn/inference-plugin/server'; import type { LlmTasksPluginStart } from '@kbn/llm-tasks-plugin/server'; +import { isEmpty } from 'lodash'; import { INVOKE_ASSISTANT_SUCCESS_EVENT } from '../lib/telemetry/event_based_telemetry'; import { AIAssistantKnowledgeBaseDataClient } from '../ai_assistant_data_clients/knowledge_base'; import { FindResponse } from '../ai_assistant_data_clients/find'; @@ -52,7 +53,6 @@ import { getLangChainMessages } from '../lib/langchain/helpers'; import { AIAssistantConversationsDataClient } from '../ai_assistant_data_clients/conversations'; import { ElasticAssistantRequestHandlerContext, GetElser } from '../types'; import { callAssistantGraph } from '../lib/langchain/graphs/default_assistant_graph'; -import { isEmpty } from 'lodash'; interface GetPluginNameFromRequestParams { request: KibanaRequest; diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts index fa1a604bbf04b..41ecb19c989ed 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts @@ -113,7 +113,7 @@ export const postActionsConnectorExecuteRoute = ( await assistantContext.getAIAssistantConversationsDataClient(); const promptsDataClient = await assistantContext.getAIAssistantPromptsDataClient(); - const contentReferencesStore = newContentReferencesStore() + const contentReferencesStore = newContentReferencesStore(); onLlmResponse = async ( content: string, diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts index fd0c6be49d8bd..3295dad4ea5bf 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts @@ -21,7 +21,7 @@ import { ElasticAssistantPluginRouter } from '../../types'; import { buildResponse } from '../utils'; import { EsConversationSchema } from '../../ai_assistant_data_clients/conversations/types'; import { transformESSearchToConversations } from '../../ai_assistant_data_clients/conversations/transforms'; -import { DEFAULT_PLUGIN_NAME, performChecks } from '../helpers'; +import { performChecks } from '../helpers'; export const findUserConversationsRoute = (router: ElasticAssistantPluginRouter) => { router.versioned diff --git a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/alert_counts/alert_counts_tool.ts b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/alert_counts/alert_counts_tool.ts index bbc9ec2db1ba6..0e13d5006f1f6 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/alert_counts/alert_counts_tool.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/alert_counts/alert_counts_tool.ts @@ -43,7 +43,9 @@ export const ALERT_COUNTS_TOOL: AssistantTool = { func: async () => { const query = getAlertsCountQuery(alertsIndexPattern); const result = await esClient.search(query); - const alertsCountReference = contentReferencesStore.add((p) => securityAlertsPageReference(p.id)); + const alertsCountReference = contentReferencesStore.add((p) => + securityAlertsPageReference(p.id) + ); const reference = `\n${contentReferenceString(alertsCountReference)}`; diff --git a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/knowledge_base/knowledge_base_retrieval_tool.ts b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/knowledge_base/knowledge_base_retrieval_tool.ts index 3fb1d283ff094..5ecd6a9a70940 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/knowledge_base/knowledge_base_retrieval_tool.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/knowledge_base/knowledge_base_retrieval_tool.ts @@ -58,8 +58,7 @@ export const KNOWLEDGE_BASE_RETRIEVAL_TOOL: AssistantTool = { required: false, }); - return JSON.stringify(docs.map(enrichDocument(contentReferencesStore))); - + return JSON.stringify(docs.map(enrichDocument(contentReferencesStore))); }, tags: ['knowledge-base'], // TODO: Remove after ZodAny is fixed https://github.com/langchain-ai/langchainjs/blob/main/langchain-core/src/tools.ts diff --git a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/open_and_acknowledged_alerts/open_and_acknowledged_alerts_tool.ts b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/open_and_acknowledged_alerts/open_and_acknowledged_alerts_tool.ts index 858233833a46c..c454ffd1e7426 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/open_and_acknowledged_alerts/open_and_acknowledged_alerts_tool.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/open_and_acknowledged_alerts/open_and_acknowledged_alerts_tool.ts @@ -96,7 +96,11 @@ export const OPEN_AND_ACKNOWLEDGED_ALERTS_TOOL: AssistantTool = { }); const hitId = x._id; - const citation = hitId && `\nCitation,${contentReferenceBlock(contentReferencesStore.add((p) => securityAlertReference(p.id, hitId)))}`; + const citation = + hitId && + `\nCitation,${contentReferenceBlock( + contentReferencesStore.add((p) => securityAlertReference(p.id, hitId)) + )}`; return `${transformed}${citation ?? ''}`; }) diff --git a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/product_docs/product_documentation_tool.ts b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/product_docs/product_documentation_tool.ts index 569d3d2450aa9..e001883bb4a32 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/product_docs/product_documentation_tool.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/product_docs/product_documentation_tool.ts @@ -75,16 +75,13 @@ export const PRODUCT_DOCUMENTATION_TOOL: AssistantTool = { functionCalling: 'auto', }); + const enrichedDocuments = response.documents.map(enrichDocument(contentReferencesStore)); - const enrichedDocuments = response.documents.map(enrichDocument(contentReferencesStore)); - - return { - content: { - documents: enrichedDocuments, - }, - }; - - + return { + content: { + documents: enrichedDocuments, + }, + }; }, tags: ['product-documentation'], // TODO: Remove after ZodAny is fixed https://github.com/langchain-ai/langchainjs/blob/main/langchain-core/src/tools.ts diff --git a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/security_labs/security_labs_tool.ts b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/security_labs/security_labs_tool.ts index 8342141c361a1..f826c976c5d32 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/security_labs/security_labs_tool.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/assistant/tools/security_labs/security_labs_tool.ts @@ -52,13 +52,13 @@ export const SECURITY_LABS_KNOWLEDGE_BASE_TOOL: AssistantTool = { }); const reference = contentReferencesStore.add((p) => - knowledgeBaseReference(p.id, 'Elastic Security Labs content', 'securityLabsId') - ); + knowledgeBaseReference(p.id, 'Elastic Security Labs content', 'securityLabsId') + ); // TODO: Token pruning const result = JSON.stringify(docs).substring(0, 20000); - const citation = contentReferenceString(reference) + const citation = contentReferenceString(reference); return `${result}\n${citation}`; }, tags: ['security-labs', 'knowledge-base'],