From 0136d07e6dc0d2a5399d9faa01eaa541a3ff1edb Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 11:09:03 -0700 Subject: [PATCH 1/7] work --- .../graphs/default_assistant_graph/helpers.ts | 28 ++++++------ .../nodes/model_input.ts | 4 +- .../server/lib/prompt/prompts.ts | 2 +- .../server/routes/evaluate/post_evaluate.ts | 43 ++++++++++--------- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts index 7a5ec37e34511..f811e81ab794c 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts @@ -136,17 +136,21 @@ export const streamGraph = async ({ // Stream is from openai functions agent let finalMessage = ''; - const stream = assistantGraph.streamEvents(inputs, { - callbacks: [ - apmTracer, - ...(traceOptions?.tracers ?? []), - ...(telemetryTracer ? [telemetryTracer] : []), - ], - runName: DEFAULT_ASSISTANT_GRAPH_ID, - streamMode: 'values', - tags: traceOptions?.tags ?? [], - version: 'v1', - }); + const stream = assistantGraph.streamEvents( + inputs, + { + callbacks: [ + apmTracer, + ...(traceOptions?.tracers ?? []), + ...(telemetryTracer ? [telemetryTracer] : []), + ], + runName: DEFAULT_ASSISTANT_GRAPH_ID, + streamMode: 'values', + tags: traceOptions?.tags ?? [], + version: 'v1', + }, + inputs?.llmType === 'inference' ? { includeNames: ['Summarizer'] } : undefined + ); const pushStreamUpdate = async () => { for await (const { event, data, tags } of stream) { @@ -155,8 +159,6 @@ export const streamGraph = async ({ const chunk = data?.chunk; const msg = chunk.message; if (msg?.tool_call_chunks && msg?.tool_call_chunks.length > 0) { - // I don't think we hit this anymore because of our check for AGENT_NODE_TAG - // however, no harm to keep it in /* empty */ } else if (!didEnd) { push({ payload: msg.content, type: 'content' }); diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts index 4e03b5be1bf3b..eb72e103b34a9 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts @@ -22,7 +22,9 @@ interface ModelInputParams extends NodeParamsBase { export function modelInput({ logger, state }: ModelInputParams): Partial { logger.debug(() => `${NodeType.MODEL_INPUT}: Node state:\n${JSON.stringify(state, null, 2)}`); - const hasRespondStep = state.isStream && (state.isOssModel || state.llmType === 'bedrock'); + const hasRespondStep = + state.isStream && + (state.isOssModel || state.llmType === 'bedrock' || state.llmType === 'inference'); return { hasRespondStep, diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts index a9a2f166399e8..af52a396c523c 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts @@ -20,7 +20,7 @@ const BASE_GEMINI_PROMPT = const KB_CATCH = 'If the knowledge base tool gives empty results, do your best to answer the question from the perspective of an expert security analyst.'; export const GEMINI_SYSTEM_PROMPT = `${BASE_GEMINI_PROMPT} ${KB_CATCH} {include_citations_prompt_placeholder}`; -export const BEDROCK_SYSTEM_PROMPT = `Use tools as often as possible, as they have access to the latest data and syntax. Always return value from NaturalLanguageESQLTool as is. Never return tags in the response, but make sure to include tags content in the response. Do not reflect on the quality of the returned search results in your response.`; +export const BEDROCK_SYSTEM_PROMPT = `Use tools as often as possible, as they have access to the latest data and syntax. Never return tags in the response, but make sure to include tags content in the response. Do not reflect on the quality of the returned search results in your response. Return the exact response from NaturalLanguageESQLTool verbatim. Do not modify, summarize, analyze, or comment on the response in any way. Do not add any explanation or additional content before or after the response. Simply return it exactly as received, including all formatting and whitespace.`; export const GEMINI_USER_PROMPT = `Now, always using the tools at your disposal, step by step, come up with a response to this request:\n\n`; export const STRUCTURED_SYSTEM_PROMPT = `Respond to the human as helpfully and accurately as possible. ${KNOWLEDGE_HISTORY} You have access to the following tools: 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 9a9342f60baa9..9e3a71699da49 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 @@ -26,7 +26,7 @@ import { buildRouteValidationWithZod } from '@kbn/elastic-assistant-common/impl/ import { getDefaultArguments } from '@kbn/langchain/server'; import { StructuredTool } from '@langchain/core/tools'; import { - createOpenAIFunctionsAgent, + createOpenAIToolsAgent, createStructuredChatAgent, createToolCallingAgent, } from 'langchain/agents'; @@ -331,26 +331,27 @@ export const postEvaluateRoute = ( savedObjectsClient, }); - const agentRunnable = isOpenAI - ? await createOpenAIFunctionsAgent({ - llm, - tools, - prompt: formatPrompt(defaultSystemPrompt), - streamRunnable: false, - }) - : llmType && ['bedrock', 'gemini'].includes(llmType) - ? createToolCallingAgent({ - llm, - tools, - prompt: formatPrompt(defaultSystemPrompt), - streamRunnable: false, - }) - : await createStructuredChatAgent({ - llm, - tools, - prompt: formatPromptStructured(defaultSystemPrompt), - streamRunnable: false, - }); + const agentRunnable = + isOpenAI || llmType === 'inference' + ? await createOpenAIToolsAgent({ + llm, + tools, + prompt: formatPrompt(defaultSystemPrompt), + streamRunnable: false, + }) + : llmType && ['bedrock', 'gemini'].includes(llmType) + ? createToolCallingAgent({ + llm, + tools, + prompt: formatPrompt(defaultSystemPrompt), + streamRunnable: false, + }) + : await createStructuredChatAgent({ + llm, + tools, + prompt: formatPromptStructured(defaultSystemPrompt), + streamRunnable: false, + }); return { connectorId: connector.id, From fa10307de0adb8d5e3af5e1581527bf7f142aa66 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 11:19:22 -0700 Subject: [PATCH 2/7] get inference provider --- .../packages/security-ai-prompts/index.ts | 2 +- .../security-ai-prompts/src/get_prompt.ts | 6 +++--- .../nodes/model_input.ts | 19 ++++++++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/x-pack/solutions/security/packages/security-ai-prompts/index.ts b/x-pack/solutions/security/packages/security-ai-prompts/index.ts index f15668e5ef156..e0f14721022ca 100644 --- a/x-pack/solutions/security/packages/security-ai-prompts/index.ts +++ b/x-pack/solutions/security/packages/security-ai-prompts/index.ts @@ -6,7 +6,7 @@ */ export { promptType } from './src/saved_object_mappings'; -export { getPrompt, getPromptsByGroupId } from './src/get_prompt'; +export { getPrompt, getPromptsByGroupId, resolveProviderAndModel } from './src/get_prompt'; export { type PromptArray, type Prompt, diff --git a/x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts b/x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts index 74aaf83cea84b..edf01bb0392ac 100644 --- a/x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts +++ b/x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts @@ -129,15 +129,15 @@ export const getPrompt = async ({ return prompt; }; -const resolveProviderAndModel = async ({ +export const resolveProviderAndModel = async ({ providedProvider, providedModel, connectorId, actionsClient, providedConnector, }: { - providedProvider: string | undefined; - providedModel: string | undefined; + providedProvider?: string; + providedModel?: string; connectorId: string; actionsClient: PublicMethodsOf; providedConnector?: Connector; diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts index eb72e103b34a9..f0848727a09c9 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { resolveProviderAndModel } from '@kbn/security-ai-prompts'; import { NodeType } from '../constants'; import { NodeParamsBase, AgentState } from '../types'; @@ -19,12 +20,20 @@ interface ModelInputParams extends NodeParamsBase { * @param logger - The scoped logger * @param state - The current state of the graph */ -export function modelInput({ logger, state }: ModelInputParams): Partial { +export async function modelInput({ + actionsClient, + logger, + state, +}: ModelInputParams): Promise> { logger.debug(() => `${NodeType.MODEL_INPUT}: Node state:\n${JSON.stringify(state, null, 2)}`); - - const hasRespondStep = - state.isStream && - (state.isOssModel || state.llmType === 'bedrock' || state.llmType === 'inference'); + const { provider } = + state.llmType === 'inference' + ? await resolveProviderAndModel({ + connectorId: state.connectorId, + actionsClient, + }) + : { provider: state.llmType }; + const hasRespondStep = state.isStream && (state.isOssModel || provider === 'bedrock'); return { hasRespondStep, From 61dc8ba38de1c090877766e666af94ccc4d059d1 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 11:35:34 -0700 Subject: [PATCH 3/7] provider --- .../graphs/default_assistant_graph/graph.ts | 4 ++++ .../graphs/default_assistant_graph/helpers.ts | 2 +- .../graphs/default_assistant_graph/index.ts | 9 +++++++++ .../nodes/model_input.ts | 17 +++-------------- .../graphs/default_assistant_graph/types.ts | 2 ++ 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts index 3cf2aa0ba92c5..bafd7c472bdf7 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts @@ -127,6 +127,10 @@ export const getDefaultAssistantGraph = ({ value: (x: boolean, y?: boolean) => y ?? x, default: () => contentReferencesEnabled, }, + provider: { + value: (x: string, y?: string) => y ?? x, + default: () => '', + }, }; // Default node parameters diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts index f811e81ab794c..d868eac03d101 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.ts @@ -149,7 +149,7 @@ export const streamGraph = async ({ tags: traceOptions?.tags ?? [], version: 'v1', }, - inputs?.llmType === 'inference' ? { includeNames: ['Summarizer'] } : undefined + inputs?.provider === 'bedrock' ? { includeNames: ['Summarizer'] } : undefined ); const pushStreamUpdate = async () => { diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts index 06cc55791f5f1..c2997cc623147 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts @@ -15,6 +15,7 @@ import { 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 { resolveProviderAndModel } from '@kbn/security-ai-prompts'; import { promptGroupId } from '../../../prompt/local_prompt_object'; import { getModelOrOss } from '../../../prompt/helpers'; import { getPrompt, promptDictionary } from '../../../prompt'; @@ -183,6 +184,13 @@ export const callAssistantGraph: AgentExecutor = async ({ logger ) : undefined; + const { provider } = + !llmType || llmType === 'inference' + ? await resolveProviderAndModel({ + connectorId, + actionsClient, + }) + : { provider: llmType }; const assistantGraph = getDefaultAssistantGraph({ agentRunnable, dataClients, @@ -205,6 +213,7 @@ export const callAssistantGraph: AgentExecutor = async ({ isStream, isOssModel, input: latestMessage[0]?.content as string, + provider: provider ?? '', }; if (isStream) { diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts index f0848727a09c9..3eff3da149d01 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { resolveProviderAndModel } from '@kbn/security-ai-prompts'; import { NodeType } from '../constants'; import { NodeParamsBase, AgentState } from '../types'; @@ -20,20 +19,10 @@ interface ModelInputParams extends NodeParamsBase { * @param logger - The scoped logger * @param state - The current state of the graph */ -export async function modelInput({ - actionsClient, - logger, - state, -}: ModelInputParams): Promise> { +export function modelInput({ logger, state }: ModelInputParams): Partial { logger.debug(() => `${NodeType.MODEL_INPUT}: Node state:\n${JSON.stringify(state, null, 2)}`); - const { provider } = - state.llmType === 'inference' - ? await resolveProviderAndModel({ - connectorId: state.connectorId, - actionsClient, - }) - : { provider: state.llmType }; - const hasRespondStep = state.isStream && (state.isOssModel || provider === 'bedrock'); + console.log('state.provider ==>', state.provider); + const hasRespondStep = state.isStream && (state.isOssModel || state.provider === 'bedrock'); return { hasRespondStep, diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/types.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/types.ts index a196229a2481e..af3c315a189d4 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/types.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/types.ts @@ -25,6 +25,7 @@ export interface GraphInputs { isStream?: boolean; isOssModel?: boolean; input: string; + provider: string; responseLanguage?: string; } @@ -37,6 +38,7 @@ export interface AgentState extends AgentStateBase { isStream: boolean; isOssModel: boolean; llmType: string; + provider: string; responseLanguage: string; connectorId: string; conversation: ConversationResponse | undefined; From dd10090dab09ac98f87449b3a30dff8f77480f29 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 11:41:47 -0700 Subject: [PATCH 4/7] rm log --- .../graphs/default_assistant_graph/nodes/model_input.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts index 3eff3da149d01..a7537820a5e1d 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/nodes/model_input.ts @@ -21,7 +21,6 @@ interface ModelInputParams extends NodeParamsBase { */ export function modelInput({ logger, state }: ModelInputParams): Partial { logger.debug(() => `${NodeType.MODEL_INPUT}: Node state:\n${JSON.stringify(state, null, 2)}`); - console.log('state.provider ==>', state.provider); const hasRespondStep = state.isStream && (state.isOssModel || state.provider === 'bedrock'); return { From c2a236167ad9202e0d521711298d270a186aad72 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 11:59:46 -0700 Subject: [PATCH 5/7] tests --- .../default_assistant_graph/helpers.test.ts | 3 +++ .../default_assistant_graph/index.test.ts | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.test.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.test.ts index b3f9dade72250..8e64625e39ce2 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.test.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/helpers.test.ts @@ -56,6 +56,7 @@ describe('streamGraph', () => { input: 'input', responseLanguage: 'English', llmType: 'openai', + provider: 'openai', connectorId: '123', }, logger: mockLogger, @@ -291,6 +292,7 @@ describe('streamGraph', () => { inputs: { ...requestArgs.inputs, llmType: 'gemini', + provider: 'gemini', }, }); @@ -306,6 +308,7 @@ describe('streamGraph', () => { inputs: { ...requestArgs.inputs, llmType: 'bedrock', + provider: 'bedrock', }, }); diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.test.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.test.ts index f2327130b6fe6..9bd6730417b1d 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.test.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.test.ts @@ -20,12 +20,15 @@ import { } from 'langchain/agents'; import { contentReferencesStoreFactoryMock } from '@kbn/elastic-assistant-common/impl/content_references/content_references_store/__mocks__/content_references_store.mock'; import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks'; +import { resolveProviderAndModel } from '@kbn/security-ai-prompts'; jest.mock('./graph'); jest.mock('./helpers'); jest.mock('langchain/agents'); jest.mock('@kbn/langchain/server/tracers/apm'); jest.mock('@kbn/langchain/server/tracers/telemetry'); +jest.mock('@kbn/security-ai-prompts'); const getDefaultAssistantGraphMock = getDefaultAssistantGraph as jest.Mock; +const resolveProviderAndModelMock = resolveProviderAndModel as jest.Mock; describe('callAssistantGraph', () => { const mockDataClients = { anonymizationFieldsDataClient: { @@ -83,6 +86,9 @@ describe('callAssistantGraph', () => { jest.clearAllMocks(); (mockDataClients?.kbDataClient?.isInferenceEndpointExists as jest.Mock).mockResolvedValue(true); getDefaultAssistantGraphMock.mockReturnValue({}); + resolveProviderAndModelMock.mockResolvedValue({ + provider: 'bedrock', + }); (invokeGraph as jest.Mock).mockResolvedValue({ output: 'test-output', traceData: {}, @@ -224,5 +230,23 @@ describe('callAssistantGraph', () => { expect(createOpenAIToolsAgent).not.toHaveBeenCalled(); expect(createToolCallingAgent).not.toHaveBeenCalled(); }); + it('does not calls resolveProviderAndModel when llmType === openai', async () => { + const params = { ...defaultParams, llmType: 'openai' }; + await callAssistantGraph(params); + + expect(resolveProviderAndModelMock).not.toHaveBeenCalled(); + }); + it('calls resolveProviderAndModel when llmType === inference', async () => { + const params = { ...defaultParams, llmType: 'inference' }; + await callAssistantGraph(params); + + expect(resolveProviderAndModelMock).toHaveBeenCalled(); + }); + it('calls resolveProviderAndModel when llmType === undefined', async () => { + const params = { ...defaultParams, llmType: undefined }; + await callAssistantGraph(params); + + expect(resolveProviderAndModelMock).toHaveBeenCalled(); + }); }); }); From 52ff53e746b812b0ecf1f6c639be1f91a122582d Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 30 Jan 2025 16:39:57 -0700 Subject: [PATCH 6/7] more better --- .../plugins/elastic_assistant/server/lib/prompt/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts index af52a396c523c..fc3d7d68ecce0 100644 --- a/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts +++ b/x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts @@ -20,7 +20,7 @@ const BASE_GEMINI_PROMPT = const KB_CATCH = 'If the knowledge base tool gives empty results, do your best to answer the question from the perspective of an expert security analyst.'; export const GEMINI_SYSTEM_PROMPT = `${BASE_GEMINI_PROMPT} ${KB_CATCH} {include_citations_prompt_placeholder}`; -export const BEDROCK_SYSTEM_PROMPT = `Use tools as often as possible, as they have access to the latest data and syntax. Never return tags in the response, but make sure to include tags content in the response. Do not reflect on the quality of the returned search results in your response. Return the exact response from NaturalLanguageESQLTool verbatim. Do not modify, summarize, analyze, or comment on the response in any way. Do not add any explanation or additional content before or after the response. Simply return it exactly as received, including all formatting and whitespace.`; +export const BEDROCK_SYSTEM_PROMPT = `Use tools as often as possible, as they have access to the latest data and syntax. Never return tags in the response, but make sure to include tags content in the response. Do not reflect on the quality of the returned search results in your response. ALWAYS return the exact response from NaturalLanguageESQLTool verbatim in the final response, without adding further description.`; export const GEMINI_USER_PROMPT = `Now, always using the tools at your disposal, step by step, come up with a response to this request:\n\n`; export const STRUCTURED_SYSTEM_PROMPT = `Respond to the human as helpfully and accurately as possible. ${KNOWLEDGE_HISTORY} You have access to the following tools: From 2e87e12d460bc4a6fad658e561681ba99dc12f6a Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 31 Jan 2025 14:37:12 -0700 Subject: [PATCH 7/7] add inference to eval connector dropdown --- .../settings/evaluation_settings/evaluation_settings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/evaluation_settings/evaluation_settings.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/evaluation_settings/evaluation_settings.tsx index ffbcad48d1cac..5e15dfcd4c8c4 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/evaluation_settings/evaluation_settings.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/evaluation_settings/evaluation_settings.tsx @@ -50,7 +50,7 @@ const AS_PLAIN_TEXT: EuiComboBoxSingleSelectionShape = { asPlainText: true }; */ export const EvaluationSettings: React.FC = React.memo(() => { const { actionTypeRegistry, http, setTraceOptions, toasts, traceOptions } = useAssistantContext(); - const { data: connectors } = useLoadConnectors({ http }); + const { data: connectors } = useLoadConnectors({ http, inferenceEnabled: true }); const { mutate: performEvaluation, isLoading: isPerformingEvaluation } = usePerformEvaluation({ http, toasts,