Skip to content

Commit

Permalink
[Connectors][GenAI] Inference Service Kibana connector (#189027)
Browse files Browse the repository at this point in the history
## Summary
Resolves #188043

This PR adds new connector which is define integration with Elastic
Inference Endpoint via [Inference
APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html)
The lifecycle of the Inference Endpoint are managed by the connector
registered handlers:

- `preSaveHook` -
[create](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html)
new Inference Endpoint in the connector create mode (`isEdit === false`)
and
[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)
in the connector edit mode (`isEdit === true`)
- `postSaveHook` - check if the connector SO was created/updated and if
not removes Inference Endpoint from preSaveHook
- `postDeleteHook` -
[delete](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html)
Inference Endpoint if connector was deleted.

In the Kibana Stack Management Connectors, its represented with the new
card (Technical preview badge):

<img width="1261" alt="Screenshot 2024-09-27 at 2 11 12 PM"
src="https://github.com/user-attachments/assets/dcbcce1f-06e7-4d08-8b77-0ba4105354f8">

To simplify the future integration with AI Assistants, the Connector
consists from the two main UI parts: provider selector and required
provider settings, which will be always displayed
<img width="862" alt="Screenshot 2024-10-07 at 7 59 09 AM"
src="https://github.com/user-attachments/assets/87bae493-c642-479e-b28f-6150354608dd">

and Additional options, which contains optional provider settings and
Task Type configuration:

<img width="861" alt="Screenshot 2024-10-07 at 8 00 15 AM"
src="https://github.com/user-attachments/assets/2341c034-6198-4731-8ce7-e22e6c6fb20f">


subActions corresponds to the different taskTypes Inference API
supports. Each of the task type has its own Inference Perform params.
Currently added:

- completion & completionStream
- rerank
- text_embedding
- sparse_embedding

Follow up work:

1. Collapse/expand Additional options, when the connector flyout/modal
has AI Assistant as a context (path through the extending context
implementation on the connector framework level)
2. Add support for additional params for Completion subAction to be able
to path functions
3. Add support for tokens usage Dashboard, when inference API will
include the used tokens count in the response
4. Add functionality and UX for migration from existing specific AI
connectors to the Inference connector with proper provider and
completion task
5. Integrate Connector with the AI Assistants

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: István Zoltán Szabó <[email protected]>
Co-authored-by: Liam Thompson <[email protected]>
Co-authored-by: Steph Milovic <[email protected]>
  • Loading branch information
5 people authored Oct 13, 2024
1 parent 122647b commit 288d41d
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 @@ -1681,6 +1681,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 288d41d

Please sign in to comment.