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

[Obs AI Assistant] unskip and update summarize.spec.ts for serverless #204790

Merged
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import {
LlmProxy,
createLlmProxy,
} from '@kbn/test-suites-xpack/observability_ai_assistant_api_integration/common/create_llm_proxy';
import {
clearKnowledgeBase,
createKnowledgeBaseModel,
deleteInferenceEndpoint,
deleteKnowledgeBaseModel,
TINY_ELSER,
} from '@kbn/test-suites-xpack/observability_ai_assistant_api_integration/tests/knowledge_base/helpers';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { invokeChatCompleteWithFunctionRequest } from './helpers';
import {
Expand All @@ -22,12 +29,15 @@ import type { InternalRequestHeader, RoleCredentials } from '../../../../../../.
export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const log = getService('log');
const ml = getService('ml');
const es = getService('es');
const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient');
const svlUserManager = getService('svlUserManager');
const svlCommonApi = getService('svlCommonApi');

// Skipped until Elser is available in tests
describe.skip('when calling summarize function', () => {
describe('when calling summarize function', function () {
// TODO: https://github.com/elastic/kibana/issues/192751
this.tags(['skipMKI']);
let roleAuthc: RoleCredentials;
let internalReqHeader: InternalRequestHeader;
let proxy: LlmProxy;
Expand All @@ -36,6 +46,19 @@ export default function ApiTest({ getService }: FtrProviderContext) {
before(async () => {
roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('editor');
internalReqHeader = svlCommonApi.getInternalRequestHeader();

await createKnowledgeBaseModel(ml);
await observabilityAIAssistantAPIClient
.slsAdmin({
endpoint: 'POST /internal/observability_ai_assistant/kb/setup',
params: {
query: {
model_id: TINY_ELSER.id,
},
},
})
.expect(200);

proxy = await createLlmProxy(log);
connectorId = await createProxyActionConnector({
supertest,
Expand All @@ -57,10 +80,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
name: 'summarize',
trigger: MessageRole.User,
arguments: JSON.stringify({
id: 'my-id',
title: 'My Title',
text: 'Hello world',
is_correction: false,
confidence: 1,
confidence: 'high',
public: false,
}),
},
Expand All @@ -72,6 +95,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
after(async () => {
proxy.close();
await deleteActionConnector({ supertest, connectorId, log, roleAuthc, internalReqHeader });
await deleteKnowledgeBaseModel(ml);
await clearKnowledgeBase(es);
await deleteInferenceEndpoint({ es });
});

it('persists entry in knowledge base', async () => {
Expand All @@ -80,12 +106,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {
params: {
query: {
query: '',
sortBy: 'doc_id',
sortBy: 'title',
sortDirection: 'asc',
},
},
});

const { role, public: isPublic, text, type, user, title } = res.body.entries[0];

expect(role).to.eql('assistant_summarization');
expect(isPublic).to.eql(false);
expect(text).to.eql('Hello world');
expect(type).to.eql('contextual');
expect(user?.name).to.eql('elastic_editor'); // "editor" in stateful
expect(title).to.eql('My Title');
expect(res.body.entries).to.have.length(1);
});
});
Expand Down
Loading