Skip to content

Commit

Permalink
[8.x] [Connectors][GenAI] Inference Service Kibana connector (elastic…
Browse files Browse the repository at this point in the history
…#189027) (elastic#196035)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Connectors][GenAI] Inference Service Kibana connector
(elastic#189027)](elastic#189027)

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

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

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-13T20:39:09Z","message":"[Connectors][GenAI]
Inference Service Kibana connector (elastic#189027)\n\n## Summary\r\nResolves
https://github.com/elastic/kibana/issues/188043\r\n\r\nThis PR adds new
connector which is define integration with Elastic\r\nInference Endpoint
via
[Inference\r\nAPIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html)\r\nThe
lifecycle of the Inference Endpoint are managed by the
connector\r\nregistered handlers:\r\n\r\n- `preSaveHook`
-\r\n[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nnew
Inference Endpoint in the connector create mode (`isEdit ===
false`)\r\nand\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)+[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nin
the connector edit mode (`isEdit === true`)\r\n- `postSaveHook` - check
if the connector SO was created/updated and if\r\nnot removes Inference
Endpoint from preSaveHook\r\n- `postDeleteHook`
-\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)\r\nInference
Endpoint if connector was deleted.\r\n\r\nIn the Kibana Stack Management
Connectors, its represented with the new\r\ncard (Technical preview
badge):\r\n\r\n<img width=\"1261\" alt=\"Screenshot 2024-09-27 at 2 11
12 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/dcbcce1f-06e7-4d08-8b77-0ba4105354f8\">\r\n\r\nTo
simplify the future integration with AI Assistants, the
Connector\r\nconsists from the two main UI parts: provider selector and
required\r\nprovider settings, which will be always displayed\r\n<img
width=\"862\" alt=\"Screenshot 2024-10-07 at 7 59
09 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/87bae493-c642-479e-b28f-6150354608dd\">\r\n\r\nand
Additional options, which contains optional provider settings
and\r\nTask Type configuration:\r\n\r\n<img width=\"861\"
alt=\"Screenshot 2024-10-07 at 8 00
15 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/2341c034-6198-4731-8ce7-e22e6c6fb20f\">\r\n\r\n\r\nsubActions
corresponds to the different taskTypes Inference API\r\nsupports. Each
of the task type has its own Inference Perform params.\r\nCurrently
added:\r\n\r\n- completion & completionStream\r\n- rerank\r\n-
text_embedding\r\n- sparse_embedding\r\n\r\nFollow up work:\r\n\r\n1.
Collapse/expand Additional options, when the connector
flyout/modal\r\nhas AI Assistant as a context (path through the
extending context\r\nimplementation on the connector framework
level)\r\n2. Add support for additional params for Completion subAction
to be able\r\nto path functions\r\n3. Add support for tokens usage
Dashboard, when inference API will\r\ninclude the used tokens count in
the response\r\n4. Add functionality and UX for migration from existing
specific AI\r\nconnectors to the Inference connector with proper
provider and\r\ncompletion task\r\n5. Integrate Connector with the AI
Assistants\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
István Zoltán Szabó <[email protected]>\r\nCo-authored-by: Liam
Thompson
<[email protected]>\r\nCo-authored-by: Steph
Milovic
<[email protected]>","sha":"288d41d61ec2389b2e8856da75fd0f3107f9c484","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","release_note:feature","Feature:Actions/ConnectorTypes","8.16
candidate","v8.16.0","backport:version"],"title":"[Connectors][GenAI]
Inference Service Kibana
connector","number":189027,"url":"https://github.com/elastic/kibana/pull/189027","mergeCommit":{"message":"[Connectors][GenAI]
Inference Service Kibana connector (elastic#189027)\n\n## Summary\r\nResolves
https://github.com/elastic/kibana/issues/188043\r\n\r\nThis PR adds new
connector which is define integration with Elastic\r\nInference Endpoint
via
[Inference\r\nAPIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html)\r\nThe
lifecycle of the Inference Endpoint are managed by the
connector\r\nregistered handlers:\r\n\r\n- `preSaveHook`
-\r\n[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nnew
Inference Endpoint in the connector create mode (`isEdit ===
false`)\r\nand\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)+[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nin
the connector edit mode (`isEdit === true`)\r\n- `postSaveHook` - check
if the connector SO was created/updated and if\r\nnot removes Inference
Endpoint from preSaveHook\r\n- `postDeleteHook`
-\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)\r\nInference
Endpoint if connector was deleted.\r\n\r\nIn the Kibana Stack Management
Connectors, its represented with the new\r\ncard (Technical preview
badge):\r\n\r\n<img width=\"1261\" alt=\"Screenshot 2024-09-27 at 2 11
12 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/dcbcce1f-06e7-4d08-8b77-0ba4105354f8\">\r\n\r\nTo
simplify the future integration with AI Assistants, the
Connector\r\nconsists from the two main UI parts: provider selector and
required\r\nprovider settings, which will be always displayed\r\n<img
width=\"862\" alt=\"Screenshot 2024-10-07 at 7 59
09 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/87bae493-c642-479e-b28f-6150354608dd\">\r\n\r\nand
Additional options, which contains optional provider settings
and\r\nTask Type configuration:\r\n\r\n<img width=\"861\"
alt=\"Screenshot 2024-10-07 at 8 00
15 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/2341c034-6198-4731-8ce7-e22e6c6fb20f\">\r\n\r\n\r\nsubActions
corresponds to the different taskTypes Inference API\r\nsupports. Each
of the task type has its own Inference Perform params.\r\nCurrently
added:\r\n\r\n- completion & completionStream\r\n- rerank\r\n-
text_embedding\r\n- sparse_embedding\r\n\r\nFollow up work:\r\n\r\n1.
Collapse/expand Additional options, when the connector
flyout/modal\r\nhas AI Assistant as a context (path through the
extending context\r\nimplementation on the connector framework
level)\r\n2. Add support for additional params for Completion subAction
to be able\r\nto path functions\r\n3. Add support for tokens usage
Dashboard, when inference API will\r\ninclude the used tokens count in
the response\r\n4. Add functionality and UX for migration from existing
specific AI\r\nconnectors to the Inference connector with proper
provider and\r\ncompletion task\r\n5. Integrate Connector with the AI
Assistants\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
István Zoltán Szabó <[email protected]>\r\nCo-authored-by: Liam
Thompson
<[email protected]>\r\nCo-authored-by: Steph
Milovic
<[email protected]>","sha":"288d41d61ec2389b2e8856da75fd0f3107f9c484"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/189027","number":189027,"mergeCommit":{"message":"[Connectors][GenAI]
Inference Service Kibana connector (elastic#189027)\n\n## Summary\r\nResolves
https://github.com/elastic/kibana/issues/188043\r\n\r\nThis PR adds new
connector which is define integration with Elastic\r\nInference Endpoint
via
[Inference\r\nAPIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html)\r\nThe
lifecycle of the Inference Endpoint are managed by the
connector\r\nregistered handlers:\r\n\r\n- `preSaveHook`
-\r\n[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nnew
Inference Endpoint in the connector create mode (`isEdit ===
false`)\r\nand\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)+[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)\r\nin
the connector edit mode (`isEdit === true`)\r\n- `postSaveHook` - check
if the connector SO was created/updated and if\r\nnot removes Inference
Endpoint from preSaveHook\r\n- `postDeleteHook`
-\r\n[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)\r\nInference
Endpoint if connector was deleted.\r\n\r\nIn the Kibana Stack Management
Connectors, its represented with the new\r\ncard (Technical preview
badge):\r\n\r\n<img width=\"1261\" alt=\"Screenshot 2024-09-27 at 2 11
12 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/dcbcce1f-06e7-4d08-8b77-0ba4105354f8\">\r\n\r\nTo
simplify the future integration with AI Assistants, the
Connector\r\nconsists from the two main UI parts: provider selector and
required\r\nprovider settings, which will be always displayed\r\n<img
width=\"862\" alt=\"Screenshot 2024-10-07 at 7 59
09 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/87bae493-c642-479e-b28f-6150354608dd\">\r\n\r\nand
Additional options, which contains optional provider settings
and\r\nTask Type configuration:\r\n\r\n<img width=\"861\"
alt=\"Screenshot 2024-10-07 at 8 00
15 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/2341c034-6198-4731-8ce7-e22e6c6fb20f\">\r\n\r\n\r\nsubActions
corresponds to the different taskTypes Inference API\r\nsupports. Each
of the task type has its own Inference Perform params.\r\nCurrently
added:\r\n\r\n- completion & completionStream\r\n- rerank\r\n-
text_embedding\r\n- sparse_embedding\r\n\r\nFollow up work:\r\n\r\n1.
Collapse/expand Additional options, when the connector
flyout/modal\r\nhas AI Assistant as a context (path through the
extending context\r\nimplementation on the connector framework
level)\r\n2. Add support for additional params for Completion subAction
to be able\r\nto path functions\r\n3. Add support for tokens usage
Dashboard, when inference API will\r\ninclude the used tokens count in
the response\r\n4. Add functionality and UX for migration from existing
specific AI\r\nconnectors to the Inference connector with proper
provider and\r\ncompletion task\r\n5. Integrate Connector with the AI
Assistants\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
István Zoltán Szabó <[email protected]>\r\nCo-authored-by: Liam
Thompson
<[email protected]>\r\nCo-authored-by: Steph
Milovic
<[email protected]>","sha":"288d41d61ec2389b2e8856da75fd0f3107f9c484"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <[email protected]>
  • Loading branch information
kibanamachine and YulNaumenko authored Oct 13, 2024
1 parent 34b8d2b commit 0c6ab08
Show file tree
Hide file tree
Showing 76 changed files with 7,251 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,11 @@ x-pack/test/security_solution_cypress/cypress/tasks/expandable_flyout @elastic/
/x-pack/plugins/stack_connectors/server/connector_types/gemini @elastic/security-generative-ai @elastic/obs-ai-assistant @elastic/appex-ai-infra
/x-pack/plugins/stack_connectors/common/gemini @elastic/security-generative-ai @elastic/obs-ai-assistant @elastic/appex-ai-infra

# Inference API
/x-pack/plugins/stack_connectors/public/connector_types/inference @elastic/appex-ai-infra @elastic/security-generative-ai @elastic/obs-ai-assistant
/x-pack/plugins/stack_connectors/server/connector_types/inference @elastic/appex-ai-infra @elastic/security-generative-ai @elastic/obs-ai-assistant
/x-pack/plugins/stack_connectors/common/inference @elastic/appex-ai-infra @elastic/security-generative-ai @elastic/obs-ai-assistant

## 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 @@ -28,6 +28,10 @@ a| <<gemini-action-type,{gemini}>>

| Send a request to {gemini}.

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

| Send a request to {inference}.

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

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


The {infer} connector uses the {es} client to send requests to an {infer} service. The connector uses the <<execute-connector-api,run connector API>> to send the request.

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

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

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

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

{infer-cap} connectors have the following configuration properties:

Name:: The name of the connector.
Service:: The supported {infer} service provider.
Task type:: The {infer} task type, it depends on the selected service.
Inference ID:: The unique identifier of the {infer} endpoint.
Provider configuration:: Settings for service configuration.
Provider secrets:: Configuration for authentication.
Task type configuration:: Settings for task type configuration.

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

You can test connectors using the <<execute-connector-api,run connector API>> or
while creating or editing the connector in {kib}. For example:

[role="screenshot"]
image::management/connectors/images/inference-completion-params.png[{infer} params test]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.
[float]
[[inference-connector-actions]]
=== {infer-cap} connector actions

The {infer} actions have the following configuration properties. Properties depend on the selected task type.

[float]
[[inference-connector-perform-completion]]
==== Completion

The following example performs a completion task on the example question.
Input::
The text on which you want to perform the {infer} task. For example:
+
[source,text]
--
{
input: 'What is Elastic?'
}
--

[float]
[[inference-connector-perform-text-embedding]]
==== Text embedding

The following example performs a text embedding task.
Input::
The text on which you want to perform the {infer} task. For example:
+
[source,text]
--
{
input: 'The sky above the port was the color of television tuned to a dead channel.',
task_settings: {
input_type: 'ingest'
}
}
--
Input type::
An optional string that overwrites the connector's default model.

[float]
[[inference-connector-perform-rerank]]
==== Reranking

The following example performs a reranking task on the example input.
Input::
The text on which you want to perform the {infer} task. Should be a string array. For example:
+
[source,text]
--
{
input: ['luke', 'like', 'leia', 'chewy', 'r2d2', 'star', 'wars'],
query: 'star wars main character'
}
--
Query::
The search query text.

[float]
[[inference-connector-perform-sparse-embedding]]
==== Sparse embedding

The following example performs a sparse embedding task on the example sentence.
Input::
The text on which you want to perform the {infer} task. For example:
+
[source,text]
--
{
input: 'The sky above the port was the color of television tuned to a dead channel.'
}
--

[float]
[[inference-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 apply these settings 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 @@ -4,6 +4,7 @@ include::action-types/crowdstrike.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/inference.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
1 change: 1 addition & 0 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,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 an <<inference-action-type,{inference} connector>>, specifies the Elastic {inference} request.
* 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
11 changes: 11 additions & 0 deletions oas_docs/examples/get_connector_types_generativeai_response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ value:
supported_feature_ids:
- generativeAIForSecurity
is_system_action_type: false
- id: .inference
name: Inference API
enabled: true
enabled_in_config: true
enabled_in_license: true
minimum_license_required: enterprise
supported_feature_ids:
- generativeAIForSecurity
- generativeAIForObservability
- generativeAIForSearchPlayground
is_system_action_type: false
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ export const useLoadActionTypes = ({
http,
featureId: GenerativeAIForSecurityConnectorFeatureId,
});
const sortedData = queryResult.sort((a, b) => a.name.localeCompare(b.name));

const actionTypeKey = {
bedrock: '.bedrock',
openai: '.gen-ai',
gemini: '.gemini',
};

const sortedData = queryResult
.filter((p) =>
[actionTypeKey.bedrock, actionTypeKey.openai, actionTypeKey.gemini].includes(p.id)
)
.sort((a, b) => a.name.localeCompare(b.name));
return sortedData;
},
{
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/common/connector_feature_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const compatibilityGenerativeAIForObservability = i18n.translate(
const compatibilityGenerativeAIForSearchPlayground = i18n.translate(
'xpack.actions.availableConnectorFeatures.compatibility.generativeAIForSearchPlayground',
{
defaultMessage: 'Generative AI for Search Playground',
defaultMessage: 'Generative AI for Search',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: The type of connector. For example, `.email`, `.index`, `.jira`, `.
enum:
- .bedrock
- .gemini
- .inference
- .cases-webhook
- .d3security
- .email
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
title: Connector request properties for an Inference API connector
description: Defines properties for connectors when type is `.inference`.
type: object
required:
- provider
- taskType
- inferenceId
properties:
provider:
type: string
description: The Inference API service provider.
taskType:
type: string
description: The Inference task type supported by provider.
providerConfig:
type: object
description: The provider settings.
taskTypeConfig:
type: object
description: The task type settings.
inferenceId:
type: string
description: The task type settings.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Connector secrets properties for an AI Connector
description: Defines secrets for connectors when type is `.inference`.
type: object
required:
- providerSecrets
properties:
providerSecrets:
type: object
description: The service account credentials. The service account could have different type of properties to encode.
Loading

0 comments on commit 0c6ab08

Please sign in to comment.