Skip to content

Commit

Permalink
[8.x] [Obs AI Assistant] unskip and update summarize.spec.ts for serv…
Browse files Browse the repository at this point in the history
…erless (#204790) (#204822)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Obs AI Assistant] unskip and update summarize.spec.ts for serverless
(#204790)](#204790)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-18T18:23:32Z","message":"[Obs
AI Assistant] unskip and update summarize.spec.ts for serverless
(#204790)\n\nCloses
https://github.com/elastic/kibana/issues/192497\r\n\r\n- Unskips
summarize.spec.ts. It was originally skipped because\r\ntiny_elser was
not available on CI.\r\n- Adds `this.tags(['skipMKI']` due
to\r\nhttps://github.com//issues/192751\r\n\r\nRelated:
https://github.com/elastic/kibana/pull/199134","sha":"4af270661478013a001cb1875fa3087f87e1f914","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:Obs
AI Assistant"],"title":"[Obs AI Assistant] unskip and update
summarize.spec.ts for
serverless","number":204790,"url":"https://github.com/elastic/kibana/pull/204790","mergeCommit":{"message":"[Obs
AI Assistant] unskip and update summarize.spec.ts for serverless
(#204790)\n\nCloses
https://github.com/elastic/kibana/issues/192497\r\n\r\n- Unskips
summarize.spec.ts. It was originally skipped because\r\ntiny_elser was
not available on CI.\r\n- Adds `this.tags(['skipMKI']` due
to\r\nhttps://github.com//issues/192751\r\n\r\nRelated:
https://github.com/elastic/kibana/pull/199134","sha":"4af270661478013a001cb1875fa3087f87e1f914"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204790","number":204790,"mergeCommit":{"message":"[Obs
AI Assistant] unskip and update summarize.spec.ts for serverless
(#204790)\n\nCloses
https://github.com/elastic/kibana/issues/192497\r\n\r\n- Unskips
summarize.spec.ts. It was originally skipped because\r\ntiny_elser was
not available on CI.\r\n- Adds `this.tags(['skipMKI']` due
to\r\nhttps://github.com//issues/192751\r\n\r\nRelated:
https://github.com/elastic/kibana/pull/199134","sha":"4af270661478013a001cb1875fa3087f87e1f914"}}]}]
BACKPORT-->

Co-authored-by: Sandra G <[email protected]>
  • Loading branch information
kibanamachine and neptunian authored Dec 19, 2024
1 parent 013c054 commit faa193b
Showing 1 changed file with 39 additions and 5 deletions.
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

0 comments on commit faa193b

Please sign in to comment.