Skip to content

Commit

Permalink
Gemini connector integration (#183668)
Browse files Browse the repository at this point in the history
  • Loading branch information
honeyn303 authored Jun 6, 2024
1 parent 9a4ceaf commit 1ff87eb
Show file tree
Hide file tree
Showing 54 changed files with 3,353 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,11 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/
/x-pack/plugins/stack_connectors/server/connector_types/bedrock @elastic/security-generative-ai
/x-pack/plugins/stack_connectors/common/bedrock @elastic/security-generative-ai

# Gemini
/x-pack/plugins/stack_connectors/public/connector_types/gemini @elastic/security-generative-ai
/x-pack/plugins/stack_connectors/server/connector_types/gemini @elastic/security-generative-ai
/x-pack/plugins/stack_connectors/common/gemini @elastic/security-generative-ai

## Defend Workflows owner connectors
/x-pack/plugins/stack_connectors/public/connector_types/sentinelone @elastic/security-defend-workflows
/x-pack/plugins/stack_connectors/server/connector_types/sentinelone @elastic/security-defend-workflows
Expand Down
4 changes: 4 additions & 0 deletions docs/management/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ a| <<d3security-action-type,D3 Security>>

| Send a request to D3 Security.

a| <<gemini-action-type,{gemini}>>

| Send a request to {gemini}.

a| <<email-action-type,Email>>

| Send email from your server.
Expand Down
74 changes: 74 additions & 0 deletions docs/management/connectors/action-types/gemini.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[[gemini-action-type]]
== {gemini} connector and action
++++
<titleabbrev>{gemini}</titleabbrev>
++++
:frontmatter-description: Add a connector that can send requests to {gemini}.
:frontmatter-tags-products: [kibana]
:frontmatter-tags-content-type: [how-to]
:frontmatter-tags-user-goals: [configure]


The {gemini} connector uses https://github.com/axios/axios[axios] to send a POST request to {gemini}. The connector uses the <<execute-connector-api,run connector API>> to send the request.

[float]
[[define-gemini-ui]]
=== Create connectors in {kib}

You can create connectors in *{stack-manage-app} > {connectors-ui}*. For example:

[role="screenshot"]
image::management/connectors/images/gemini-connector.png[{gemini} connector]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
[[gemini-connector-configuration]]
==== Connector configuration

{gemini} connectors have the following configuration properties:

Name:: The name of the connector.
API URL:: The {gemini} request URL.
PROJECT ID:: The project which has Vertex AI endpoint enabled.
Region:: The GCP region where the Vertex AI endpoint enabled.
Default model:: The GAI model for {gemini} to use. Current support is for the Google Gemini models, defaulting to gemini-1.5-pro-preview-0409. The model can be set on a per request basis by including a "model" parameter alongside the request body.
Credentials JSON:: The GCP service account JSON file for authentication.

[float]
[[gemini-action-configuration]]
=== Test connectors

You can test connectors with the <<execute-connector-api,run connector API>> or
as you're creating or editing the connector in {kib}. For example:

[role="screenshot"]
image::management/connectors/images/gemini-params.png[{gemini} params test]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

The {gemini} actions have the following configuration properties.

Body:: A stringified JSON payload sent to the {gemini} Invoke Model API URL. For example:
+
[source,text]
--

{
body: JSON.stringify({
contents: [{
role: user,
parts: [{ text: 'Write the first line of a story about a magic backpack.' }]
}],
generation_config: {
temperature: 0,
maxOutputTokens: 8192
}
})
}
--
Model:: An optional string that will overwrite the connector's default model. For

[float]
[[gemini-connector-networking-configuration]]
=== Connector networking configuration

Use the <<action-settings, Action configuration settings>> to customize connector networking configurations, such as proxies, certificates, or TLS settings. You can set configurations that apply to all your connectors or use `xpack.actions.customHostSettings` to set per-host configurations.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/management/connectors/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include::action-types/bedrock.asciidoc[leveloffset=+1]
include::action-types/cases-action-type.asciidoc[leveloffset=+1]
include::action-types/d3security.asciidoc[leveloffset=+1]
include::action-types/email.asciidoc[leveloffset=+1]
include::action-types/gemini.asciidoc[leveloffset=+1]
include::action-types/resilient.asciidoc[leveloffset=+1]
include::action-types/index.asciidoc[leveloffset=+1]
include::action-types/jira.asciidoc[leveloffset=+1]
Expand Down
7 changes: 6 additions & 1 deletion docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ WARNING: This feature is available in {kib} 7.17.4 and 8.3.0 onwards but is not
A boolean value indicating that a footer with a relevant link should be added to emails sent as alerting actions. Default: true.

`xpack.actions.enabledActionTypes` {ess-icon}::
A list of action types that are enabled. It defaults to `["*"]`, enabling all types. The names for built-in {kib} action types are prefixed with a `.` and include: `.email`, `.index`, `.jira`, `.opsgenie`, `.pagerduty`, `.resilient`, `.server-log`, `.servicenow`, .`servicenow-itom`, `.servicenow-sir`, `.slack`, `.swimlane`, `.teams`, `.tines`, `.torq`, `.xmatters`, `.gen-ai`, `.bedrock`, `.d3security`, and `.webhook`. An empty list `[]` will disable all action types.
A list of action types that are enabled. It defaults to `["*"]`, enabling all types. The names for built-in {kib} action types are prefixed with a `.` and include: `.email`, `.index`, `.jira`, `.opsgenie`, `.pagerduty`, `.resilient`, `.server-log`, `.servicenow`, .`servicenow-itom`, `.servicenow-sir`, `.slack`, `.swimlane`, `.teams`, `.tines`, `.torq`, `.xmatters`, `.gen-ai`, `.bedrock`, `.gemini`, `.d3security`, and `.webhook`. An empty list `[]` will disable all action types.
+
Disabled action types will not appear as an option when creating new connectors, but existing connectors and actions of that type will remain in {kib} and will not function.

Expand Down Expand Up @@ -277,6 +277,7 @@ A configuration URL that varies by connector:
+
--
* For an <<bedrock-action-type,{bedrock} connector>>, specifies the {bedrock} request URL.
* For an <<gemini-action-type,{gemini} connector>>, specifies the {gemini} request URL.
* For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI request URL.
* For a <<resilient-action-type,{ibm-r} connector>>, specifies the {ibm-r} instance URL.
* For a <<jira-action-type,Jira connector>>, specifies the Jira instance URL.
Expand Down Expand Up @@ -341,6 +342,7 @@ The default model to use for requests, which varies by connector:
+
--
* For an <<bedrock-action-type,{bedrock} connector>>, current support is for the Anthropic Claude models. Defaults to `anthropic.claude-3-sonnet-20240229-v1:0`.
* For a <<gemini-action-type,{gemini} connector>>, current support is for the Gemini models. Defaults to `gemini-1.5-pro-preview-0409`.
* For a <<openai-action-type,OpenAI connector>>, it is optional and applicable only when `xpack.actions.preconfigured.<connector-id>.config.apiProvider` is `OpenAI`.
--

Expand Down Expand Up @@ -483,6 +485,9 @@ For an <<bedrock-action-type,{bedrock} connector>>, specifies the AWS access key

`xpack.actions.preconfigured.<connector-id>.secrets.apikey`::
An API key secret that varies by connector:

`xpack.actions.preconfigured.<connector-id>.secrets.credentialsJSON`::
For an <<gemini-action-type,{gemini} connector>>, specifies the GCP service account credentials JSON file for authentication.
+
--
* For a <<openai-action-type,OpenAI connector>>, specifies the OpenAI or Azure OpenAI API key for authentication.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@
"getopts": "^2.2.5",
"getos": "^3.1.0",
"globby": "^11.1.0",
"google-auth-library": "^9.10.0",
"gpt-tokenizer": "^2.1.2",
"handlebars": "4.7.8",
"he": "^1.2.0",
Expand Down
10 changes: 10 additions & 0 deletions x-pack/packages/kbn-elastic-assistant/impl/mock/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ export const mockActionTypes = [
isSystemActionType: true,
supportedFeatureIds: ['generativeAI'],
} as ActionType,
{
id: '.gemini',
name: 'Gemini',
enabled: true,
enabledInConfig: true,
enabledInLicense: true,
minimumLicenseRequired: 'basic',
isSystemActionType: true,
supportedFeatureIds: ['generativeAI'],
} as ActionType,
];

export const mockConnectors: AIConnector[] = [
Expand Down
Loading

0 comments on commit 1ff87eb

Please sign in to comment.