From e3994831ff3c6f337a209bcd3d2f93344eb787a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 7 Nov 2024 00:25:30 +0100 Subject: [PATCH] Enable summarisation spec (#199134) This enables the api test that covers summarisation. It was originally skipped because tiny_elser was not available on CI. Now it is we can effectively test storing and retrieving entries from the knowledge base. --- .../server/plugin.ts | 5 ---- .../complete/functions/summarize.spec.ts | 30 +++++++++++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts index 81f4e24d4d21f..3bdff9eb17606 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts @@ -32,7 +32,6 @@ import { ObservabilityAIAssistantPluginSetupDependencies, ObservabilityAIAssistantPluginStartDependencies, } from './types'; -import { addLensDocsToKb } from './service/knowledge_base_service/kb_docs/lens'; import { registerFunctions } from './functions'; import { recallRankingEvent } from './analytics/recall_ranking'; import { initLangtrace } from './service/client/instrumentation/init_langtrace'; @@ -164,10 +163,6 @@ export class ObservabilityAIAssistantPlugin service.register(registerFunctions); - if (this.config.enableKnowledgeBase) { - addLensDocsToKb({ service, logger: this.logger.get('kb').get('lens') }); - } - registerServerRoutes({ core, logger: this.logger, diff --git a/x-pack/test/observability_ai_assistant_api_integration/tests/complete/functions/summarize.spec.ts b/x-pack/test/observability_ai_assistant_api_integration/tests/complete/functions/summarize.spec.ts index 238be31220aa9..923e8b0206070 100644 --- a/x-pack/test/observability_ai_assistant_api_integration/tests/complete/functions/summarize.spec.ts +++ b/x-pack/test/observability_ai_assistant_api_integration/tests/complete/functions/summarize.spec.ts @@ -14,18 +14,32 @@ import { createProxyActionConnector, deleteActionConnector, } from '../../../common/action_connectors'; +import { + clearKnowledgeBase, + createKnowledgeBaseModel, + deleteKnowledgeBaseModel, +} from '../../knowledge_base/helpers'; 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'); - // Skipped until Elser is available in tests - describe.skip('when calling summarize function', () => { + describe('when calling summarize function', () => { let proxy: LlmProxy; let connectorId: string; before(async () => { + await clearKnowledgeBase(es); + await createKnowledgeBaseModel(ml); + await observabilityAIAssistantAPIClient + .editorUser({ + endpoint: 'POST /internal/observability_ai_assistant/kb/setup', + }) + .expect(200); + proxy = await createLlmProxy(log); connectorId = await createProxyActionConnector({ supertest, log, port: proxy.getPort() }); @@ -44,7 +58,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { id: 'my-id', text: 'Hello world', is_correction: false, - confidence: 1, + confidence: 'high', public: false, }), }, @@ -55,7 +69,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { proxy.close(); + await deleteActionConnector({ supertest, connectorId, log }); + await deleteKnowledgeBaseModel(ml); }); it('persists entry in knowledge base', async () => { @@ -70,6 +86,14 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); + const { role, public: isPublic, text, type, user, id } = 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('editor'); + expect(id).to.eql('my-id'); expect(res.body.entries).to.have.length(1); }); });