Skip to content

Commit

Permalink
[8.15] [Security assistant] Fix Bedrock Langgraph ESQL tool calling (#…
Browse files Browse the repository at this point in the history
…189810) (#189845)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Security assistant] Fix Bedrock Langgraph ESQL tool calling
(#189810)](#189810)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Patryk
Kopyciński","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-08-02T23:47:27Z","message":"[Security
assistant] Fix Bedrock Langgraph ESQL tool calling (#189810)\n\n##
Summary\r\n\r\nAddresses the Bedrock portion of
https://github.com/elastic/kibana/issues/189771.\r\n\r\nWhen using the
Bedrock connector and asking the AI Assistant ES|QL generation
questions, the AI Assistant is now consistently using the
`ESQLKnowledgeBaseTool` and responding with correct ES|QL syntax. This
is an example of a [successful
trace](https://smith.langchain.com/o/b739bf24-7ba4-4994-b632-65dd677ac74e/projects/p/34f01a8b-e9a5-4df6-8cc2-163960220718?timeModel=%7B%22duration%22%3A%227d%22%7D&peek=9b7d5f31-c98b-4f63-bb9b-b2df95863218).\r\n\r\n![ma](https://github.com/user-attachments/assets/1e173e00-8c9e-4a40-ac2e-a2ee36ae57fa)","sha":"83490a0a3e70b7514918bf98263c96030a3939fd","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:
SecuritySolution","ci:cloud-deploy","Team:Security Generative
AI","v8.15.0","v8.16.0"],"title":"[Security assistant] Fix Bedrock
Langgraph ESQL tool
calling","number":189810,"url":"https://github.com/elastic/kibana/pull/189810","mergeCommit":{"message":"[Security
assistant] Fix Bedrock Langgraph ESQL tool calling (#189810)\n\n##
Summary\r\n\r\nAddresses the Bedrock portion of
https://github.com/elastic/kibana/issues/189771.\r\n\r\nWhen using the
Bedrock connector and asking the AI Assistant ES|QL generation
questions, the AI Assistant is now consistently using the
`ESQLKnowledgeBaseTool` and responding with correct ES|QL syntax. This
is an example of a [successful
trace](https://smith.langchain.com/o/b739bf24-7ba4-4994-b632-65dd677ac74e/projects/p/34f01a8b-e9a5-4df6-8cc2-163960220718?timeModel=%7B%22duration%22%3A%227d%22%7D&peek=9b7d5f31-c98b-4f63-bb9b-b2df95863218).\r\n\r\n![ma](https://github.com/user-attachments/assets/1e173e00-8c9e-4a40-ac2e-a2ee36ae57fa)","sha":"83490a0a3e70b7514918bf98263c96030a3939fd"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/189810","number":189810,"mergeCommit":{"message":"[Security
assistant] Fix Bedrock Langgraph ESQL tool calling (#189810)\n\n##
Summary\r\n\r\nAddresses the Bedrock portion of
https://github.com/elastic/kibana/issues/189771.\r\n\r\nWhen using the
Bedrock connector and asking the AI Assistant ES|QL generation
questions, the AI Assistant is now consistently using the
`ESQLKnowledgeBaseTool` and responding with correct ES|QL syntax. This
is an example of a [successful
trace](https://smith.langchain.com/o/b739bf24-7ba4-4994-b632-65dd677ac74e/projects/p/34f01a8b-e9a5-4df6-8cc2-163960220718?timeModel=%7B%22duration%22%3A%227d%22%7D&peek=9b7d5f31-c98b-4f63-bb9b-b2df95863218).\r\n\r\n![ma](https://github.com/user-attachments/assets/1e173e00-8c9e-4a40-ac2e-a2ee36ae57fa)","sha":"83490a0a3e70b7514918bf98263c96030a3939fd"}}]}]
BACKPORT-->

Co-authored-by: Patryk Kopyciński <[email protected]>
  • Loading branch information
kibanamachine and patrykkopycinski authored Aug 3, 2024
1 parent 3f9ba59 commit 6c9cc62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const callAssistantGraph: AgentExecutor<true | false> = async ({
const modelExists = await esStore.isModelInstalled();

// Create a chain that uses the ELSER backed ElasticsearchStore, override k=10 for esql query generation for now
const chain = RetrievalQAChain.fromLLM(llm, esStore.asRetriever(10));
const chain = RetrievalQAChain.fromLLM(getLlmInstance(), esStore.asRetriever(10));

// Check if KB is available
const isEnabledKnowledgeBase = (await dataClients?.kbDataClient?.isModelDeployed()) ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const geminiToolCallingAgentPrompt = ChatPromptTemplate.fromMessages([
[
'system',
'You are a helpful assistant. ALWAYS use the provided tools. Use tools as often as possible, as they have access to the latest data and syntax.\n\n' +
`The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question, which is "{input}". The final response should never be empty.`,
"The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question. The final response should never be empty.",
],
['placeholder', '{chat_history}'],
['human', '{input}'],
Expand Down

0 comments on commit 6c9cc62

Please sign in to comment.