-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution] [Elastic AI Assistant] Adds internal Get Evaluate API and migrates Post Evaluate API to OAS
#175338
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f12be81
Migrates post evaluate API to OAS and adds new get evaluate API
spong b686fd5
Merge branch 'main' of github.com:elastic/kibana into eval+++
spong bb6a8f8
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine bcce197
Linter fix
spong 6bd9426
Merge branch 'main' into eval+++
spong df1a836
Merge branch 'main' into eval+++
spong c4b569f
Merge branch 'main' into eval+++
spong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...k/packages/kbn-elastic-assistant-common/impl/schemas/evaluation/get_evaluate_route.gen.ts
This file contains hidden or 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,22 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
|
|
||
| /* | ||
| * NOTICE: Do not edit this file manually. | ||
| * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. | ||
| * | ||
| * info: | ||
| * title: Get Evaluate API endpoint | ||
| * version: 1 | ||
| */ | ||
|
|
||
| export type GetEvaluateResponse = z.infer<typeof GetEvaluateResponse>; | ||
| export const GetEvaluateResponse = z.object({ | ||
| agentExecutors: z.array(z.string()), | ||
| }); |
40 changes: 40 additions & 0 deletions
40
...kages/kbn-elastic-assistant-common/impl/schemas/evaluation/get_evaluate_route.schema.yaml
This file contains hidden or 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,40 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| title: Get Evaluate API endpoint | ||
| version: '1' | ||
| paths: | ||
| /internal/elastic_assistant/evaluate: | ||
| get: | ||
| operationId: GetEvaluate | ||
| x-codegen-enabled: true | ||
| description: Get relevant data for performing an evaluation like available sample data, agents, and evaluators | ||
| summary: Get relevant data for performing an evaluation | ||
| tags: | ||
| - Evaluation API | ||
| responses: | ||
| '200': | ||
| description: Successful response | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| agentExecutors: | ||
| type: array | ||
| items: | ||
| type: string | ||
| required: | ||
| - agentExecutors | ||
| '400': | ||
| description: Generic Error | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| statusCode: | ||
| type: number | ||
| error: | ||
| type: string | ||
| message: | ||
| type: string | ||
85 changes: 85 additions & 0 deletions
85
.../packages/kbn-elastic-assistant-common/impl/schemas/evaluation/post_evaluate_route.gen.ts
This file contains hidden or 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,85 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
|
|
||
| /* | ||
| * NOTICE: Do not edit this file manually. | ||
| * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. | ||
| * | ||
| * info: | ||
| * title: Post Evaluate API endpoint | ||
| * version: 1 | ||
| */ | ||
|
|
||
| export type OutputIndex = z.infer<typeof OutputIndex>; | ||
| export const OutputIndex = z.string().regex(/^.kibana-elastic-ai-assistant-/); | ||
|
|
||
| export type DatasetItem = z.infer<typeof DatasetItem>; | ||
| export const DatasetItem = z.object({ | ||
| id: z.string().optional(), | ||
| input: z.string(), | ||
| prediction: z.string().optional(), | ||
| reference: z.string(), | ||
| tags: z.array(z.string()).optional(), | ||
| }); | ||
|
|
||
| export type Dataset = z.infer<typeof Dataset>; | ||
| export const Dataset = z.array(DatasetItem).default([]); | ||
|
|
||
| export type PostEvaluateBody = z.infer<typeof PostEvaluateBody>; | ||
| export const PostEvaluateBody = z.object({ | ||
| dataset: Dataset.optional(), | ||
| evalPrompt: z.string().optional(), | ||
| }); | ||
|
|
||
| export type PostEvaluateRequestQuery = z.infer<typeof PostEvaluateRequestQuery>; | ||
| export const PostEvaluateRequestQuery = z.object({ | ||
| /** | ||
| * Agents parameter description | ||
| */ | ||
| agents: z.string(), | ||
| /** | ||
| * Dataset Name parameter description | ||
| */ | ||
| datasetName: z.string().optional(), | ||
| /** | ||
| * Evaluation Type parameter description | ||
| */ | ||
| evaluationType: z.string().optional(), | ||
| /** | ||
| * Eval Model parameter description | ||
| */ | ||
| evalModel: z.string().optional(), | ||
| /** | ||
| * Models parameter description | ||
| */ | ||
| models: z.string(), | ||
| /** | ||
| * Output Index parameter description | ||
| */ | ||
| outputIndex: OutputIndex, | ||
| /** | ||
| * Project Name parameter description | ||
| */ | ||
| projectName: z.string().optional(), | ||
| /** | ||
| * Run Name parameter description | ||
| */ | ||
| runName: z.string().optional(), | ||
| }); | ||
| export type PostEvaluateRequestQueryInput = z.input<typeof PostEvaluateRequestQuery>; | ||
|
|
||
| export type PostEvaluateRequestBody = z.infer<typeof PostEvaluateRequestBody>; | ||
| export const PostEvaluateRequestBody = PostEvaluateBody; | ||
| export type PostEvaluateRequestBodyInput = z.input<typeof PostEvaluateRequestBody>; | ||
|
|
||
| export type PostEvaluateResponse = z.infer<typeof PostEvaluateResponse>; | ||
| export const PostEvaluateResponse = z.object({ | ||
| evaluationId: z.string(), | ||
| success: z.boolean(), | ||
| }); |
126 changes: 126 additions & 0 deletions
126
...ages/kbn-elastic-assistant-common/impl/schemas/evaluation/post_evaluate_route.schema.yaml
This file contains hidden or 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,126 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| title: Post Evaluate API endpoint | ||
| version: '1' | ||
| paths: | ||
| /internal/elastic_assistant/evaluate: | ||
| post: | ||
| operationId: PostEvaluate | ||
| x-codegen-enabled: true | ||
| description: Perform an evaluation using sample data against a combination of Agents and Connectors | ||
| summary: Performs an evaluation of the Elastic Assistant | ||
| tags: | ||
| - Evaluation API | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/PostEvaluateBody' | ||
| parameters: | ||
| - name: agents | ||
| in: query | ||
| description: Agents parameter description | ||
| required: true | ||
| schema: | ||
| type: string | ||
| - name: datasetName | ||
| in: query | ||
| description: Dataset Name parameter description | ||
| schema: | ||
| type: string | ||
| - name: evaluationType | ||
| in: query | ||
| description: Evaluation Type parameter description | ||
| schema: | ||
| type: string | ||
| - name: evalModel | ||
| in: query | ||
| description: Eval Model parameter description | ||
| schema: | ||
| type: string | ||
| - name: models | ||
| in: query | ||
| description: Models parameter description | ||
| required: true | ||
| schema: | ||
| type: string | ||
| - name: outputIndex | ||
| in: query | ||
| description: Output Index parameter description | ||
| required: true | ||
| schema: | ||
| $ref: '#/components/schemas/OutputIndex' | ||
| - name: projectName | ||
| in: query | ||
| description: Project Name parameter description | ||
| schema: | ||
| type: string | ||
| - name: runName | ||
| in: query | ||
| description: Run Name parameter description | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: Successful response | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| evaluationId: | ||
| type: string | ||
| success: | ||
| type: boolean | ||
| required: | ||
| - evaluationId | ||
| - success | ||
| '400': | ||
| description: Generic Error | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| statusCode: | ||
| type: number | ||
| error: | ||
| type: string | ||
| message: | ||
| type: string | ||
| components: | ||
| schemas: | ||
| OutputIndex: | ||
| type: string | ||
| pattern: '^.kibana-elastic-ai-assistant-' | ||
| DatasetItem: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: string | ||
| input: | ||
| type: string | ||
| prediction: | ||
| type: string | ||
| reference: | ||
| type: string | ||
| tags: | ||
| type: array | ||
| items: | ||
| type: string | ||
| required: | ||
| - input | ||
| - reference | ||
| Dataset: | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/DatasetItem' | ||
| default: [] | ||
| PostEvaluateBody: | ||
| type: object | ||
| properties: | ||
| dataset: | ||
| $ref: '#/components/schemas/Dataset' | ||
| evalPrompt: | ||
| type: string |
26 changes: 26 additions & 0 deletions
26
x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts
This file contains hidden or 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,26 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| // API versioning constants | ||
| export const API_VERSIONS = { | ||
| public: { | ||
| v1: '2023-10-31', | ||
| }, | ||
| internal: { | ||
| v1: '1', | ||
| }, | ||
| }; | ||
|
|
||
| export const PUBLIC_API_ACCESS = 'public'; | ||
| export const INTERNAL_API_ACCESS = 'internal'; | ||
|
|
||
| // Evaluation Schemas | ||
| export * from './evaluation/post_evaluate_route.gen'; | ||
| export * from './evaluation/get_evaluate_route.gen'; | ||
|
|
||
| // Capabilities Schemas | ||
| export * from './capabilities/get_capabilities_route.gen'; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I re-used the existing
evaluateroute as that seemed the most ergonomic for fetching metadata that would be useful for executing an eval cycle viaPOST /evaluate.I have no plan of exposing a 'get evaluation results' endpoint at the moment (since we've been treating that data as ephemeral), so wasn't worried about any overlap here. This is an
internalAPI, so there is flexibility and it can change as needed.