-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security AI Assistant] Chat complete API (#184485)
- Loading branch information
1 parent
d00f36e
commit d5a91fc
Showing
45 changed files
with
2,090 additions
and
733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...k/packages/kbn-elastic-assistant-common/impl/schemas/chat/post_chat_complete_route.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/* | ||
* NOTICE: Do not edit this file manually. | ||
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. | ||
* | ||
* info: | ||
* title: Chat Complete API endpoint | ||
* version: 2023-10-31 | ||
*/ | ||
|
||
import { z } from 'zod'; | ||
|
||
export type RootContext = z.infer<typeof RootContext>; | ||
export const RootContext = z.literal('security'); | ||
|
||
/** | ||
* Message role. | ||
*/ | ||
export type ChatMessageRole = z.infer<typeof ChatMessageRole>; | ||
export const ChatMessageRole = z.enum(['system', 'user', 'assistant']); | ||
export type ChatMessageRoleEnum = typeof ChatMessageRole.enum; | ||
export const ChatMessageRoleEnum = ChatMessageRole.enum; | ||
|
||
export type MessageData = z.infer<typeof MessageData>; | ||
export const MessageData = z.object({}).catchall(z.unknown()); | ||
|
||
/** | ||
* AI assistant message. | ||
*/ | ||
export type ChatMessage = z.infer<typeof ChatMessage>; | ||
export const ChatMessage = z.object({ | ||
/** | ||
* Message content. | ||
*/ | ||
content: z.string().optional(), | ||
/** | ||
* Message role. | ||
*/ | ||
role: ChatMessageRole, | ||
/** | ||
* ECS object to attach to the context of the message. | ||
*/ | ||
data: MessageData.optional(), | ||
fields_to_anonymize: z.array(z.string()).optional(), | ||
}); | ||
|
||
export type ChatCompleteProps = z.infer<typeof ChatCompleteProps>; | ||
export const ChatCompleteProps = z.object({ | ||
conversationId: z.string().optional(), | ||
promptId: z.string().optional(), | ||
isStream: z.boolean().optional(), | ||
responseLanguage: z.string().optional(), | ||
langSmithProject: z.string().optional(), | ||
langSmithApiKey: z.string().optional(), | ||
connectorId: z.string(), | ||
model: z.string().optional(), | ||
persist: z.boolean(), | ||
messages: z.array(ChatMessage), | ||
}); | ||
|
||
export type ChatCompleteRequestBody = z.infer<typeof ChatCompleteRequestBody>; | ||
export const ChatCompleteRequestBody = ChatCompleteProps; | ||
export type ChatCompleteRequestBodyInput = z.input<typeof ChatCompleteRequestBody>; |
109 changes: 109 additions & 0 deletions
109
...kages/kbn-elastic-assistant-common/impl/schemas/chat/post_chat_complete_route.schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Chat Complete API endpoint | ||
version: '2023-10-31' | ||
paths: | ||
/api/elastic_assistant/chat/complete: | ||
post: | ||
operationId: ChatComplete | ||
x-codegen-enabled: true | ||
description: Creates a model response for the given chat conversation. | ||
summary: Creates a model response for the given chat conversation. | ||
tags: | ||
- Chat Complete API | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ChatCompleteProps' | ||
responses: | ||
200: | ||
description: Indicates a successful call. | ||
content: | ||
application/octet-stream: | ||
schema: | ||
type: string | ||
format: binary | ||
400: | ||
description: Generic Error | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
statusCode: | ||
type: number | ||
error: | ||
type: string | ||
message: | ||
type: string | ||
|
||
components: | ||
schemas: | ||
RootContext: | ||
type: string | ||
enum: | ||
- security | ||
|
||
ChatMessageRole: | ||
type: string | ||
description: Message role. | ||
enum: | ||
- system | ||
- user | ||
- assistant | ||
|
||
MessageData: | ||
type: object | ||
additionalProperties: true | ||
|
||
ChatMessage: | ||
type: object | ||
description: AI assistant message. | ||
required: | ||
- 'role' | ||
properties: | ||
content: | ||
type: string | ||
description: Message content. | ||
role: | ||
$ref: '#/components/schemas/ChatMessageRole' | ||
description: Message role. | ||
data: | ||
description: ECS object to attach to the context of the message. | ||
$ref: '#/components/schemas/MessageData' | ||
fields_to_anonymize: | ||
type: array | ||
items: | ||
type: string | ||
|
||
ChatCompleteProps: | ||
type: object | ||
properties: | ||
conversationId: | ||
type: string | ||
promptId: | ||
type: string | ||
isStream: | ||
type: boolean | ||
responseLanguage: | ||
type: string | ||
langSmithProject: | ||
type: string | ||
langSmithApiKey: | ||
type: string | ||
connectorId: | ||
type: string | ||
model: | ||
type: string | ||
persist: | ||
type: boolean | ||
messages: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/ChatMessage' | ||
required: | ||
- messages | ||
- persist | ||
- connectorId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.