Skip to content

[Security assistant] Fix Bedrock Langgraph ESQL tool calling#189810

Merged
andrew-goldstein merged 8 commits intoelastic:mainfrom
patrykkopycinski:fix/langgraph-esql
Aug 2, 2024
Merged

[Security assistant] Fix Bedrock Langgraph ESQL tool calling#189810
andrew-goldstein merged 8 commits intoelastic:mainfrom
patrykkopycinski:fix/langgraph-esql

Conversation

@patrykkopycinski
Copy link
Copy Markdown
Contributor

@patrykkopycinski patrykkopycinski commented Aug 2, 2024

Summary

Addresses the Bedrock portion of #189771.

When 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.

ma

@patrykkopycinski patrykkopycinski added the ci:cloud-deploy Create or update a Cloud deployment label Aug 2, 2024
@patrykkopycinski patrykkopycinski self-assigned this Aug 2, 2024
@patrykkopycinski
Copy link
Copy Markdown
Contributor Author

/ci

@patrykkopycinski
Copy link
Copy Markdown
Contributor Author

/ci

@patrykkopycinski
Copy link
Copy Markdown
Contributor Author

/ci

@andrew-goldstein andrew-goldstein marked this pull request as ready for review August 2, 2024 20:37
@andrew-goldstein andrew-goldstein requested a review from a team as a code owner August 2, 2024 20:37
…hain/graphs/default_assistant_graph/prompts.ts
Reverts change to x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts
@andrew-goldstein
Copy link
Copy Markdown
Contributor

@elasticmachine merge upstream

@andrew-goldstein andrew-goldstein added Team:Security Generative AI Security Generative AI v8.15.0 Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. labels Aug 2, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@andrew-goldstein andrew-goldstein added release_note:skip Skip the PR/issue when compiling release notes bug Fixes for quality problems that affect the customer experience labels Aug 2, 2024
@patrykkopycinski patrykkopycinski changed the title Test [Security assistant] Fix Langgraph ESQL tool calling Aug 2, 2024
@patrykkopycinski patrykkopycinski changed the title [Security assistant] Fix Langgraph ESQL tool calling [Security assistant] Fix Bedrock Langgraph ESQL tool calling Aug 2, 2024
…e-gemini-prompt-update

Restores change to the Gemini system prompt
@kibana-ci
Copy link
Copy Markdown

kibana-ci commented Aug 2, 2024

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @patrykkopycinski

Copy link
Copy Markdown
Contributor

@peluja1012 peluja1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally with Sonnet 3.5, Gemini, and gpt-4o. ES|QL generation with Sonnet (Bedrock connector) worked as expected and the ESQL tool was called every time. Also tested the RAG on alerts workflow with these models. There didn't appear to be any regressions with Gemini or gpt-4o on the RAG on alerts or ES|QL generation workflows.

It's worth noting that, as the PR description mentions, it only fixes Bedrock ES|QL generation. Gemini ES|QL generation is still not working well, although, it works better when the default System Prompt is cleared before sending the message.

@andrew-goldstein andrew-goldstein merged commit 83490a0 into elastic:main Aug 2, 2024
@andrew-goldstein andrew-goldstein deleted the fix/langgraph-esql branch August 2, 2024 23:47
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 2, 2024
…#189810)

## Summary

Addresses the Bedrock portion of elastic#189771.

When 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).

![ma](https://github.com/user-attachments/assets/1e173e00-8c9e-4a40-ac2e-a2ee36ae57fa)

(cherry picked from commit 83490a0)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.15

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Aug 3, 2024
…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":"contact@patrykkopycinski.com"},"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 <contact@patrykkopycinski.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes for quality problems that affect the customer experience ci:cloud-deploy Create or update a Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.15.0 v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants