Skip to content

Commit

Permalink
Revert "[Security Solution] [Elastic AI Assistant] Adds internal `Get…
Browse files Browse the repository at this point in the history
… Evaluate` API and migrates `Post Evaluate` API to OAS (#175338)"

This reverts commit 38f0a7a.
  • Loading branch information
jbudz committed Jan 31, 2024
1 parent be645db commit b201bf6
Show file tree
Hide file tree
Showing 29 changed files with 424 additions and 900 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts

This file was deleted.

3 changes: 1 addition & 2 deletions x-pack/packages/kbn-elastic-assistant-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

// Schema constants
export * from './impl/schemas';
export { GetCapabilitiesResponse } from './impl/schemas/capabilities/get_capabilities_route.gen';

export { defaultAssistantFeatures } from './impl/capabilities';
export type { AssistantFeatures } from './impl/capabilities';
Expand Down
49 changes: 49 additions & 0 deletions x-pack/packages/kbn-elastic-assistant/impl/assistant/api.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
fetchConnectorExecuteAction,
FetchConnectorExecuteAction,
getKnowledgeBaseStatus,
postEvaluation,
postKnowledgeBase,
} from './api';
import type { Conversation, Message } from '../assistant_context/types';
Expand Down Expand Up @@ -339,4 +340,52 @@ describe('API tests', () => {
await expect(deleteKnowledgeBase(knowledgeBaseArgs)).resolves.toThrowError('simulated error');
});
});

describe('postEvaluation', () => {
it('calls the knowledge base API when correct resource path', async () => {
(mockHttp.fetch as jest.Mock).mockResolvedValue({ success: true });
const testProps = {
http: mockHttp,
evalParams: {
agents: ['not', 'alphabetical'],
dataset: '{}',
datasetName: 'Test Dataset',
projectName: 'Test Project Name',
runName: 'Test Run Name',
evalModel: ['not', 'alphabetical'],
evalPrompt: 'evalPrompt',
evaluationType: ['not', 'alphabetical'],
models: ['not', 'alphabetical'],
outputIndex: 'outputIndex',
},
};

await postEvaluation(testProps);

expect(mockHttp.fetch).toHaveBeenCalledWith('/internal/elastic_assistant/evaluate', {
method: 'POST',
body: '{"dataset":{},"evalPrompt":"evalPrompt"}',
headers: { 'Content-Type': 'application/json' },
query: {
models: 'alphabetical,not',
agents: 'alphabetical,not',
datasetName: 'Test Dataset',
evaluationType: 'alphabetical,not',
evalModel: 'alphabetical,not',
outputIndex: 'outputIndex',
projectName: 'Test Project Name',
runName: 'Test Run Name',
},
signal: undefined,
});
});
it('returns error when error is an error', async () => {
const error = 'simulated error';
(mockHttp.fetch as jest.Mock).mockImplementation(() => {
throw new Error(error);
});

await expect(postEvaluation(knowledgeBaseArgs)).resolves.toThrowError('simulated error');
});
});
});
Loading

0 comments on commit b201bf6

Please sign in to comment.