Skip to content

Commit

Permalink
Enable summarisation spec (#199134)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sorenlouv authored Nov 6, 2024
1 parent 09dd66d commit e399483
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() });

Expand All @@ -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,
}),
},
Expand All @@ -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 () => {
Expand All @@ -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);
});
});
Expand Down

0 comments on commit e399483

Please sign in to comment.