Skip to content

Commit

Permalink
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
Browse files Browse the repository at this point in the history
…-fix'
  • Loading branch information
kibanamachine committed Feb 24, 2025
1 parent 4f65147 commit 7b69cfd
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ const AssistantComponent: React.FC<Props> = ({

return (
<>

<AnonymizedValuesAndCitationsTour conversation={currentConversation} />
<AnonymizedValuesAndCitationsTour conversation={currentConversation} />
<EuiFlexGroup direction={'row'} wrap={false} gutterSize="none">
{chatHistoryVisible && (
<EuiFlexItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,59 +255,59 @@ export const SettingsContextMenu: React.FC<Params> = React.memo(
</EuiFlexItem>
</EuiFlexGroup>
</EuiContextMenuItem>
<EuiContextMenuItem
aria-label={'show-citations'}
key={'show-citations'}
data-test-subj={'show-citations'}
>
<EuiFlexGroup direction="row" gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<ConditionalWrap
condition={!selectedConversationHasCitations}
wrap={(children) => (
<EuiToolTip
position="top"
key={'disabled-anonymize-values-tooltip'}
content={
<FormattedMessage
id="xpack.elasticAssistant.assistant.settings.showCitationsLabel.disabled.tooltip"
defaultMessage="This conversation does not contain citations."
/>
}
>
{children}
</EuiToolTip>
)}
>
<EuiSwitch
label={i18n.SHOW_CITATIONS}
checked={contentReferencesVisible}
onChange={onChangeContentReferencesVisible}
compressed
disabled={!selectedConversationHasCitations}
<EuiContextMenuItem
aria-label={'show-citations'}
key={'show-citations'}
data-test-subj={'show-citations'}
>
<EuiFlexGroup direction="row" gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<ConditionalWrap
condition={!selectedConversationHasCitations}
wrap={(children) => (
<EuiToolTip
position="top"
key={'disabled-anonymize-values-tooltip'}
content={
<FormattedMessage
id="xpack.elasticAssistant.assistant.settings.showCitationsLabel.disabled.tooltip"
defaultMessage="This conversation does not contain citations."
/>
}
>
{children}
</EuiToolTip>
)}
>
<EuiSwitch
label={i18n.SHOW_CITATIONS}
checked={contentReferencesVisible}
onChange={onChangeContentReferencesVisible}
compressed
disabled={!selectedConversationHasCitations}
/>
</ConditionalWrap>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
key={'show-citations-tooltip'}
content={
<FormattedMessage
id="xpack.elasticAssistant.assistant.settings.showCitationsLabel.tooltip"
defaultMessage="Keyboard shortcut: <bold>{keyboardShortcut}</bold>"
values={{
keyboardShortcut: isMac ? '⌥ + c' : 'Alt + c',
bold: (str) => <strong>{str}</strong>,
}}
/>
</ConditionalWrap>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
key={'show-citations-tooltip'}
content={
<FormattedMessage
id="xpack.elasticAssistant.assistant.settings.showCitationsLabel.tooltip"
defaultMessage="Keyboard shortcut: <bold>{keyboardShortcut}</bold>"
values={{
keyboardShortcut: isMac ? '⌥ + c' : 'Alt + c',
bold: (str) => <strong>{str}</strong>,
}}
/>
}
>
<EuiIcon tabIndex={0} type="iInCircle" />
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
</EuiContextMenuItem>
}
>
<EuiIcon tabIndex={0} type="iInCircle" />
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
</EuiContextMenuItem>

<EuiHorizontalRule margin="none" />
<EuiContextMenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import {
errorResult,
successResult,
} from './create_resource_installation_helper';
import {
conversationsFieldMap,
} from '../ai_assistant_data_clients/conversations/field_maps_configuration';
import { conversationsFieldMap } from '../ai_assistant_data_clients/conversations/field_maps_configuration';
import { assistantPromptsFieldMap } from '../ai_assistant_data_clients/prompts/field_maps_configuration';
import { assistantAnonymizationFieldsFieldMap } from '../ai_assistant_data_clients/anonymization_fields/field_maps_configuration';
import { AIAssistantDataClient } from '../ai_assistant_data_clients';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { APMTracer } from '@kbn/langchain/server/tracers/apm';
import { TelemetryTracer } from '@kbn/langchain/server/tracers/telemetry';
import { pruneContentReferences, MessageMetadata } from '@kbn/elastic-assistant-common';
import { getPrompt, resolveProviderAndModel } from '@kbn/security-ai-prompts';
import { isEmpty } from 'lodash';
import { localToolPrompts, promptGroupId as toolsGroupId } from '../../../prompt/tool_prompts';
import { promptGroupId } from '../../../prompt/local_prompt_object';
import { getModelOrOss } from '../../../prompt/helpers';
Expand All @@ -29,7 +30,6 @@ import { GraphInputs } from './types';
import { getDefaultAssistantGraph } from './graph';
import { invokeGraph, streamGraph } from './helpers';
import { transformESSearchToAnonymizationFields } from '../../../../ai_assistant_data_clients/anonymization_fields/helpers';
import { isEmpty } from 'lodash';

export const callAssistantGraph: AgentExecutor<true | false> = async ({
abortSignal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const ALERT_COUNTS_TOOL: AssistantTool = {
func: async () => {
const query = getAlertsCountQuery(alertsIndexPattern);
const result = await esClient.search<SearchResponse>(query);
const alertsCountReference = contentReferencesStore.add((p) => securityAlertsPageReference(p.id));
const alertsCountReference = contentReferencesStore.add((p) =>
securityAlertsPageReference(p.id)
);

const reference = `\n${contentReferenceString(alertsCountReference)}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? ''}`;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit 7b69cfd

Please sign in to comment.