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

Security AI Assistant APIs #5620

Merged
merged 39 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5746f9d
Security AI Assistant APIs
YulNaumenko Jul 29, 2024
ca2f85f
-
YulNaumenko Jul 29, 2024
9852a13
Merge branch 'main' into ai-assistant-apis
benironside Jul 31, 2024
2a4e8fa
Add to SIEM APIs page
peluja1012 Aug 1, 2024
519b388
Update path to AI-for-security
peluja1012 Aug 1, 2024
1854d35
Only conversation-api-create for now
peluja1012 Aug 1, 2024
2f2588a
Update headings levels
peluja1012 Aug 1, 2024
4d02061
Update headings levels
peluja1012 Aug 1, 2024
ff64d32
Create ai-for-security-index.asciidoc
peluja1012 Aug 1, 2024
48033a2
Update siem-apis.asciidoc
peluja1012 Aug 1, 2024
bc727ba
Update includes
peluja1012 Aug 1, 2024
32b199f
initial troubleshoot of Table of Contents / sections / page org
benironside Aug 1, 2024
97fac8d
Adds other pages to the PR and fixes build errors
benironside Aug 1, 2024
34ed9af
ToC fix
benironside Aug 1, 2024
54aef89
Moves AI Assistant API inside API docs section
benironside Aug 1, 2024
0e585f4
Changes title to "API" from "APIs"
benironside Aug 1, 2024
5fa435d
fixed the content
YulNaumenko Aug 2, 2024
09208dd
Merge branch 'main' into ai-assistant-apis
YulNaumenko Aug 2, 2024
3580fd2
Converts tables to asciidoc in chat-complete-api
natasha-moore-elastic Aug 2, 2024
376c462
Converts tables to asciidoc in conversation-api-create
natasha-moore-elastic Aug 2, 2024
2b72b0f
Converts tables to asciidoc in conversation-api-update
natasha-moore-elastic Aug 2, 2024
eb1addc
Escape links that are causing build to fail
natasha-moore-elastic Aug 2, 2024
fe9b643
Escape parentheses in md links
natasha-moore-elastic Aug 2, 2024
cd5458f
inserts escape chars in broken links
benironside Aug 2, 2024
b65d39d
Apply suggestions from code review
benironside Aug 7, 2024
5a1ff6a
Apply suggestions from code review
YulNaumenko Aug 7, 2024
97bdfb7
updated to to the comments
YulNaumenko Aug 7, 2024
80e43f2
-
YulNaumenko Aug 7, 2024
5fd5283
Merge branch 'main' into ai-assistant-apis
natasha-moore-elastic Aug 8, 2024
65bb68e
Apply suggestions from code review
YulNaumenko Aug 8, 2024
437027b
Merge remote-tracking branch 'upstream/main' into ai-assistant-apis
YulNaumenko Aug 8, 2024
9a8f827
Merge branch 'ai-assistant-apis' of github.com:YulNaumenko/security-d…
YulNaumenko Aug 8, 2024
d97a65e
Line edits of descriptions
benironside Aug 8, 2024
9ad8c75
Revert "Line edits of descriptions"
benironside Aug 8, 2024
9655441
Line edits
benironside Aug 8, 2024
88511ca
Merge branch 'main' into ai-assistant-apis
benironside Aug 8, 2024
a82d583
Merge remote-tracking branch 'refs/remotes/github-desktop-YulNaumenko…
benironside Aug 8, 2024
24685b6
minor tweak
benironside Aug 8, 2024
6da10da
minor formatting fix
benironside Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/AI-for-security/api/ai-for-security-index.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include::assistant-api-overview.asciidoc[]

include::chat-complete-api.asciidoc[]

include::conversation-api-create.asciidoc[]

include::conversation-api-delete.asciidoc[]

include::conversation-api-find.asciidoc[]

include::conversation-api-get.asciidoc[]

include::conversation-api-update.asciidoc[]

5 changes: 5 additions & 0 deletions docs/AI-for-security/api/assistant-api-overview.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[assistant-api-overview]]
[role="xpack"]
== Elastic AI Assistant API

The Elastic AI Assistant API allows you to interact with and manage Elastic AI Assistant.
235 changes: 235 additions & 0 deletions docs/AI-for-security/api/chat-complete-api.asciidoc

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions docs/AI-for-security/api/conversation-api-create.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
[[conversation-api-create]]
=== Create conversation

Create a new Elastic AI Assistant conversation.

[discrete]
=== Request URL

`POST <kibana host>:<port>/api/security_ai_assistant/current_user/conversations`

[discrete]
=== Request body

[width="100%",options="header"]
|==============================================
|Name |Type |Description |Required

|`title` |String |Conversation title. If you set it to "New chat", the AI will generate a title. |Yes
|`category` |String |Can be "assistant", "insights", or not defined. |No
|`isDefault` |Boolean |Define if conversation is a system conversation which cannot be deleted. Defaults to false. |No
|`excludeFromLastConversationStorage` |Boolean |Defines if conversation can appear as the latest conversation. |No
|`apiConfig` |<<create-apiconfig-obj,apiConfig object>> |Conversation configuration. |No
|`messages` |<<create-message-obj,messages object>> |Array of conversation messages. |No
|`replacements` |Key, Value(String, String)|List of the fields with anonymization. |No
|==============================================

[discrete]
[[create-apiconfig-obj]]
== `apiConfig` object

[width="100%",options="header"]
|==============================================
|Name |Type |Description |Required

|`connectorId` |String |Kibana connector ID. |Yes
|`actionTypeId` |String |Kibana connector action type ID. |Yes
|`defaultSystemPromptId` |String |Default system prompt ID. |Yes
|`model` |String |Specific LLM name. |No
|==============================================

[discrete]
[[create-message-obj]]
== `messages` object

[width="100%",options="header"]
|==============================================
|Name |Type |Description |Required

|`role` |String |Message role. Can be "user", "assistant", or "system". |Yes
|`content` |String |Message content to send to LLM. |Yes
|`isError` |Boolean |Define if the message is an error message instead of an LLM response. |No
|`timestamp` |String |Timestamp when the message was sent. |No
|==============================================

[discrete]
=== Example requests

*Example 1*

Creates a new conversation.

[source,console]
--------------------------------------------------
POST api/security_ai_assistant/current_user/conversations
{
"title": "The conversation title.",
"category": "assistant",
"messages": [
{
"content": "test content",
"role": "user",
"isError": false,
"timestamp": "2019-12-13T16:40:33.400Z",
"traceData": {
"traceId": "1234",
"transactionId": "2"
}
}
],
"apiConfig": {
"actionTypeId": ".gen-ai",
"connectorId": "86ab-471c-a00b-25b7e20c2d12",
"defaultSystemPromptId": "Default",
"model": "gpt-4o"
},
"isDefault": false,
"excludeFromLastConversationStorage": true,
"replacements": {
"field1": "914beb92-86ab-471c-a00b"
}
}
--------------------------------------------------

[discrete]
=== Response code

`200`
Indicates a successful call.

[discrete]
=== Response payload

A JSON conversation object with a unique `id`.

*Example 1*

Conversation response payload:

[source,json]
--------------------------------------------------
{
"id": "07805df2-6462-451a-b534-78da47873c42",
"title": "The conversation title.",
"category": "assistant",
"timestamp": "2024-07-29T06:58:15.670Z",
"updatedAt": "2024-07-29T06:58:15.670Z",
"createdAt": "2024-07-29T06:58:15.670Z",
"replacements": {
"field1": "914beb92-86ab-471c-a00b"
},
"users": [
{
"name": "elastic"
}
],
"messages": [
{
"content": "test content",
"role": "user",
"timestamp": "2019-12-13T16:40:33.400Z",
"traceData": {
"transactionId": "2",
"traceId": "1234"
}
}
],
"apiConfig": {
"connectorId": "86ab-471c-a00b-25b7e20c2d12",
"actionTypeId": ".gen-ai",
"defaultSystemPromptId": "Default",
"model": "gpt-4o"
},
"isDefault": false,
"excludeFromLastConversationStorage": true,
"namespace": "default"
}
--------------------------------------------------

44 changes: 44 additions & 0 deletions docs/AI-for-security/api/conversation-api-delete.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[[conversation-api-delete]]
=== Delete conversation

Delete an existing Elastic AI Assistant conversation by conversation ID.

[discrete]
=== Request URL

`DELETE <kibana host>:<port>/api/security_ai_assistant/current_user/conversations/{id}`


[discrete]
=== Example requests

*Example 1*

benironside marked this conversation as resolved.
Show resolved Hide resolved
Deletes an Elastic AI Assistant conversation with an `id` value of `df071e68-3c8e-4c0d-b0e7-1557e80c0319`:

[source,console]
--------------------------------------------------
DELETE api/security_ai_assistant/current_user/conversations/df071e68-3c8e-4c0d-b0e7-1557e80c0319

--------------------------------------------------

[discrete]
=== Response code

`200`
Indicates a successful call.

[discrete]
=== Response payload

An empty JSON object.

*Example 1*

Response payload:

[source,json]
--------------------------------------------------
{}
--------------------------------------------------

110 changes: 110 additions & 0 deletions docs/AI-for-security/api/conversation-api-find.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[[conversation-api-find]]
=== Find conversations

Retrieve a list of Elastic AI Assistant conversations for the current user.

[discrete]
=== Request URL

`GET <kibana host>:<port>/api/security_ai_assistant/current_user/conversations/_find`

==== URL query parameters

[width="100%",options="header"]
|==============================================
|Name |Type |Description |Required

|`page` |Number |The page number to return. Defaults to `1`.
|No
|`per_page` |Number |The number of items to return per page. Defaults to `10`.
|No
|`filter` |String |The filter query to apply on the request.
|No
|`sort_field` |String a|The field to sort the results by. Valid values are:

* `title`
* `description`
* `updated`
* `created`

|No
|`sort_order` |String a|The order to sort the results in. Valid values are:

* `asc`
* `desc`

|No
|`fields` |String a|Defines the fields of the document to return in the response.

|No

|==============================================

[discrete]
=== Example requests

*Example 1*

Get a list of the current user's conversations.

[source,console]
--------------------------------------------------
GET api/security_ai_assistant/current_user/conversations/_find?page=1&per_page=100
natasha-moore-elastic marked this conversation as resolved.
Show resolved Hide resolved
--------------------------------------------------

[discrete]
=== Response code

`200`
Indicates a successful call.

[discrete]
=== Response payload

A JSON conversation object with a unique `id`.

*Example 1*

Conversation response payload:

[source,json]
--------------------------------------------------
{
"perPage": 20,
"page": 1,
"total": 1,
"data": [
{
"timestamp": "2024-08-02T07:19:08.124Z",
"createdAt": "2024-08-02T07:19:08.124Z",
"users": [
{
"id": "u_mGBROF_q5bmFCATbLXAcCwKa0k8JvONAwSruelyKA5E_0",
"name": "elastic"
}
],
"title": "The conversation title.",
"category": "assistant",
"apiConfig": {
"connectorId": "86ab-471c-a00b-25b7e20c2d12",
"actionTypeId": ".gen-ai",
"defaultSystemPromptId": "Default",
"model": "gpt-4o"
},
"isDefault": true,
"messages": [
{
"timestamp": "2019-12-13T16:40:33.400Z",
"content": "test content",
"role": "user"
}
],
"updatedAt": "2024-08-02T07:39:45.129Z",
"replacements": {},
"namespace": "default",
"id": "a696901d-efff-4871-acbe-8123af841932"
}
]
}
--------------------------------------------------

63 changes: 63 additions & 0 deletions docs/AI-for-security/api/conversation-api-get.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[[conversation-api-get]]
=== Get conversation

Retrieve an existing Elastic AI Assistant conversation by conversation ID.

[discrete]
=== Request URL

`GET <kibana host>:<port>/api/security_ai_assistant/current_user/conversations/{id}`

[discrete]
=== Example requests

*Example 1*

Retrieves an Elastic AI Assistant conversation with an `id` value of `a696901d-efff-4871-acbe-8123af841932`:

[source,console]
--------------------------------------------------
GET api/security_ai_assistant/current_user/conversations/a696901d-efff-4871-acbe-8123af841932
--------------------------------------------------

[discrete]
=== Response code

`200`
Indicates a successful call.

[discrete]
=== Response payload

A JSON conversation object with a unique `id`.

*Example 1*

Conversation response payload:

[source,json]
--------------------------------------------------
{
"timestamp": "2024-08-02T07:19:08.124Z",
"createdAt": "2024-08-02T07:19:08.124Z",
"users": [
{
"id": "u_mGBROF_q5bmFCATbLXAcCwKa0k8JvONAwSruelyKA5E_0",
"name": "elastic"
}
],
"title": "Welcome",
"category": "assistant",
"apiConfig": {
"connectorId": "my-gpt4o-ai",
"actionTypeId": ".gen-ai"
},
"isDefault": true,
"messages": [],
"updatedAt": "2024-08-02T07:19:08.124Z",
"replacements": {},
"namespace": "default",
"id": "a696901d-efff-4871-acbe-8123af841932"
}
--------------------------------------------------

Loading