Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BedrockChat & GeminiChat #186809

Merged

Conversation

patrykkopycinski
Copy link
Contributor

@patrykkopycinski patrykkopycinski commented Jun 24, 2024

Summary

Adopted BedrockChat from @langchain/community package that adds support for tools calling
https://js.langchain.com/v0.2/docs/integrations/chat/bedrock/

Adopted ChatGoogleGenerativeAI from @langchain/google-genai package that adds support for tools calling https://js.langchain.com/v0.2/docs/integrations/chat/google_generativeai

Hidden behind FF: --xpack.securitySolution.enableExperimental=[assistantBedrockChat]

As of this PR integration_assistant is still going to use ActionsClientSimpleChatModel. After the FF will be enabled by default we will switch integration_assistant to use new chat model.

Thank you @stephmilovic a ton 🙇

@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci


let out;
try {
out = await toolExecutor.invoke(agentAction, config);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to catch Received tool input did not match expected schema errors
image

@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski patrykkopycinski self-assigned this Jun 29, 2024
@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci

@elasticmachine
Copy link
Contributor

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

@stephmilovic stephmilovic added the ci:cloud-deploy Create or update a Cloud deployment label Jul 22, 2024
Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Thanks for these changes @patrykkopycinski. When using the feature flags, I got more accurate and consistent results for Bedrock and Gemini with and without streaming. LGTM

Copy link
Member

@joemcelroy joemcelroy left a comment

Choose a reason for hiding this comment

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

Checked this PR with Patryk and due to the introduction of safety_settings, this meant some setups (like mine, no monthly billing google setup), it throws an 400 API exception.

Patryk going to discuss what we can do in this situation.

"{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"User has requested a restricted HarmBlockThreshold setting BLOCK_NONE. You can get access either (a) through an allowlist via your Google account team, or (b) by switching your account type to monthly invoiced billing via this instruction: https://cloud.google.com/billing/docs/how-to/invoiced-billing.\",\n    \"status\": \"INVALID_ARGUMENT\"\n  }\n}\n"

@stephmilovic
Copy link
Contributor

@joemcelroy I think I fixed the issue. I bubbled up this error so it will reach the user. Additionally, I scaled back the threshold from BLOCK_NONE to BLOCK_ONLY_HIGH. For whatever reason, yesterday i was getting the error 80% of the time when asking the assistant to summarize an alert and now i can't get it at all. Hoping maybe the model was just having a bad day... Regardless, you should no longer experience the error and if you do, you will get a message in the UI:
Screenshot 2024-07-23 at 9 14 02 AM

Screenshot 2024-07-23 at 9 13 30 AM

Copy link
Member

@joemcelroy joemcelroy left a comment

Choose a reason for hiding this comment

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

Looks good from playground POV

@patrykkopycinski patrykkopycinski enabled auto-merge (squash) July 23, 2024 16:42
@stephmilovic
Copy link
Contributor

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jul 23, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #15 / CustomFields renders correctly
  • [job] [logs] FTR Configs #4 / Screenshots - serverless observability UI response ops docs observability cases Observability case settings case settings screenshots

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
integrationAssistant 536 539 +3
securitySolution 5638 5641 +3
total +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.8MB 1.8MB +4.2KB
integrationAssistant 933.2KB 937.4KB +4.2KB
securitySolution 17.3MB 17.3MB +4.5KB
total +12.8KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/langchain 3 1 -2
elasticAssistant 1 2 +1
total -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 86.7KB 86.7KB +24.0B
stackConnectors 53.7KB 53.7KB +60.0B
timelines 109.3KB 113.4KB +4.2KB
total +4.3KB
Unknown metric groups

API count

id before after diff
@kbn/zod 1224 1254 +30

ESLint disabled line counts

id before after diff
@kbn/langchain 0 1 +1

Total ESLint disabled count

id before after diff
@kbn/langchain 0 1 +1

History

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

cc @patrykkopycinski

@patrykkopycinski patrykkopycinski merged commit 26dd61e into elastic:main Jul 23, 2024
44 checks passed
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.15 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.15:
- Upgrade EUI to v95.3.0 (#187342)
- Update dependency @launchdarkly/node-server-sdk to ^9.4.7 (main) (#187807)
- Update dependency @redocly/cli to ^1.17.0 (main) (#187765)

Manual backport

To create the backport manually run:

node scripts/backport --pr 186809

Questions ?

Please refer to the Backport tool documentation

@stephmilovic
Copy link
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

stephmilovic pushed a commit to stephmilovic/kibana that referenced this pull request Jul 23, 2024
## Summary

Adopted `BedrockChat` from `@langchain/community` package that adds
support for tools calling
https://js.langchain.com/v0.2/docs/integrations/chat/bedrock/

Adopted `ChatGoogleGenerativeAI ` from `@langchain/google-genai` package
that adds support for tools calling
https://js.langchain.com/v0.2/docs/integrations/chat/google_generativeai

Hidden behind FF:
`--xpack.securitySolution.enableExperimental=[assistantBedrockChat]`

As of this PR `integration_assistant` is still going to use
`ActionsClientSimpleChatModel`. After the FF will be enabled by default
we will switch `integration_assistant` to use new chat model.

Thank you @stephmilovic a ton 🙇

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Steph Milovic <[email protected]>
Co-authored-by: Garrett Spong <[email protected]>
(cherry picked from commit 26dd61e)

# Conflicts:
#	package.json
#	yarn.lock
stephmilovic added a commit that referenced this pull request Jul 23, 2024
# Backport

This will backport the following commits from `main` to `8.15`:
- [`BedrockChat` & `GeminiChat`
(#186809)](#186809)

<!--- Backport version: 8.9.8 -->

### 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-07-23T20:17:21Z","message":"`BedrockChat`
& `GeminiChat` (#186809)\n\n## Summary\r\n\r\nAdopted `BedrockChat` from
`@langchain/community` package that adds\r\nsupport for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/bedrock/\r\n\r\nAdopted
`ChatGoogleGenerativeAI ` from `@langchain/google-genai` package\r\nthat
adds support for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/google_generativeai\r\n\r\nHidden
behind
FF:\r\n`--xpack.securitySolution.enableExperimental=[assistantBedrockChat]`\r\n\r\nAs
of this PR `integration_assistant` is still going to
use\r\n`ActionsClientSimpleChatModel`. After the FF will be enabled by
default\r\nwe will switch `integration_assistant` to use new chat
model.\r\n\r\nThank you @stephmilovic a ton
🙇\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Steph Milovic <[email protected]>\r\nCo-authored-by: Garrett
Spong
<[email protected]>","sha":"26dd61efa2784c5008efede5880f514926795fe1","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:
SecuritySolution","ci:cloud-deploy","Team:Security Generative
AI","v8.15.0","v8.16.0"],"number":186809,"url":"#186809
& `GeminiChat` (#186809)\n\n## Summary\r\n\r\nAdopted `BedrockChat` from
`@langchain/community` package that adds\r\nsupport for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/bedrock/\r\n\r\nAdopted
`ChatGoogleGenerativeAI ` from `@langchain/google-genai` package\r\nthat
adds support for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/google_generativeai\r\n\r\nHidden
behind
FF:\r\n`--xpack.securitySolution.enableExperimental=[assistantBedrockChat]`\r\n\r\nAs
of this PR `integration_assistant` is still going to
use\r\n`ActionsClientSimpleChatModel`. After the FF will be enabled by
default\r\nwe will switch `integration_assistant` to use new chat
model.\r\n\r\nThank you @stephmilovic a ton
🙇\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Steph Milovic <[email protected]>\r\nCo-authored-by: Garrett
Spong
<[email protected]>","sha":"26dd61efa2784c5008efede5880f514926795fe1"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"#186809
& `GeminiChat` (#186809)\n\n## Summary\r\n\r\nAdopted `BedrockChat` from
`@langchain/community` package that adds\r\nsupport for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/bedrock/\r\n\r\nAdopted
`ChatGoogleGenerativeAI ` from `@langchain/google-genai` package\r\nthat
adds support for tools
calling\r\nhttps://js.langchain.com/v0.2/docs/integrations/chat/google_generativeai\r\n\r\nHidden
behind
FF:\r\n`--xpack.securitySolution.enableExperimental=[assistantBedrockChat]`\r\n\r\nAs
of this PR `integration_assistant` is still going to
use\r\n`ActionsClientSimpleChatModel`. After the FF will be enabled by
default\r\nwe will switch `integration_assistant` to use new chat
model.\r\n\r\nThank you @stephmilovic a ton
🙇\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Steph Milovic <[email protected]>\r\nCo-authored-by: Garrett
Spong
<[email protected]>","sha":"26dd61efa2784c5008efede5880f514926795fe1"}}]}]
BACKPORT-->

---------

Co-authored-by: Patryk Kopyciński <[email protected]>
TinLe added a commit to TinLe/kibana that referenced this pull request Jul 30, 2024
* master: (3487 commits)
  `BedrockChat` & `GeminiChat` (elastic#186809)
  [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332)
  skip flaky suite (elastic#188997)
  [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580)
  [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608)
  [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943)
  Improve SearchSource SearchRequest type (elastic#186862)
  Deprecate Search Sessions config (elastic#188037)
  [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824)
  [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746)
  [Data Forge] Add `service.logs` dataset as a  data stream (elastic#188786)
  [Console] Fix failing bulk requests (elastic#188552)
  Update dependency terser to ^5.31.2 (main) (elastic#188528)
  [APM][ECO] Telemetry (elastic#188627)
  [Fleet] Fix uninstall package validation accross space (elastic#188749)
  Update warning on `xpack.fleet.enableExperimental` (elastic#188917)
  [DOCS][Cases] Automate more screenshots for cases (elastic#188697)
  [Fleet] Fix get one agent when feature flag disabled (elastic#188953)
  chore(investigate): Add investigate-app plugin from poc (elastic#188122)
  [Monaco Editor] Add Search functionality (elastic#188337)
  ...
TinLe added a commit to TinLe/kibana that referenced this pull request Jul 30, 2024
* master: (2400 commits)
  `BedrockChat` & `GeminiChat` (elastic#186809)
  [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332)
  skip flaky suite (elastic#188997)
  [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580)
  [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608)
  [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943)
  Improve SearchSource SearchRequest type (elastic#186862)
  Deprecate Search Sessions config (elastic#188037)
  [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824)
  [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746)
  [Data Forge] Add `service.logs` dataset as a  data stream (elastic#188786)
  [Console] Fix failing bulk requests (elastic#188552)
  Update dependency terser to ^5.31.2 (main) (elastic#188528)
  [APM][ECO] Telemetry (elastic#188627)
  [Fleet] Fix uninstall package validation accross space (elastic#188749)
  Update warning on `xpack.fleet.enableExperimental` (elastic#188917)
  [DOCS][Cases] Automate more screenshots for cases (elastic#188697)
  [Fleet] Fix get one agent when feature flag disabled (elastic#188953)
  chore(investigate): Add investigate-app plugin from poc (elastic#188122)
  [Monaco Editor] Add Search functionality (elastic#188337)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

8 participants