diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts index e71d40b51aef7..1571487765c09 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/functions/route.ts @@ -124,6 +124,7 @@ const functionSummariseRoute = createObservabilityAIAssistantServerRoute({ endpoint: 'POST /internal/observability_ai_assistant/functions/summarize', params: t.type({ body: t.type({ + title: t.string, text: nonEmptyStringRt, confidence: t.union([t.literal('low'), t.literal('medium'), t.literal('high')]), is_correction: toBooleanRt, @@ -142,6 +143,7 @@ const functionSummariseRoute = createObservabilityAIAssistantServerRoute({ } const { + title, confidence, is_correction: isCorrection, text, @@ -151,6 +153,7 @@ const functionSummariseRoute = createObservabilityAIAssistantServerRoute({ return client.addKnowledgeBaseEntry({ entry: { + title, confidence, id: v4(), is_correction: isCorrection, diff --git a/x-pack/test/observability_ai_assistant_functional/tests/knowledge_base_management/index.spec.ts b/x-pack/test/observability_ai_assistant_functional/tests/knowledge_base_management/index.spec.ts index e7f7690a0f524..7a5a51ae58b6a 100644 --- a/x-pack/test/observability_ai_assistant_functional/tests/knowledge_base_management/index.spec.ts +++ b/x-pack/test/observability_ai_assistant_functional/tests/knowledge_base_management/index.spec.ts @@ -8,6 +8,7 @@ import expect from '@kbn/expect'; import { subj as testSubjSelector } from '@kbn/test-subj-selector'; import { + clearKnowledgeBase, createKnowledgeBaseModel, deleteKnowledgeBaseModel, } from '../../../observability_ai_assistant_api_integration/tests/knowledge_base/helpers'; @@ -20,6 +21,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte const testSubjects = getService('testSubjects'); const log = getService('log'); const ml = getService('ml'); + const es = getService('es'); const { common } = getPageObjects(['common']); async function saveKbEntry({ @@ -33,6 +35,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte endpoint: 'POST /internal/observability_ai_assistant/functions/summarize', params: { body: { + title: 'Favourite color', text, confidence: 'high', is_correction: false, @@ -45,6 +48,8 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte describe('Knowledge management tab', () => { before(async () => { + await clearKnowledgeBase(es); + // create a knowledge base model await createKnowledgeBaseModel(ml); @@ -60,7 +65,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte }); after(async () => { - await Promise.all([deleteKnowledgeBaseModel(ml), ui.auth.logout()]); + await Promise.all([deleteKnowledgeBaseModel(ml), clearKnowledgeBase(es), ui.auth.logout()]); }); describe('when the LLM calls the "summarize" function for two different users', () => { @@ -75,22 +80,22 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte const rows = await Promise.all( entryTitleCells.map(async (cell) => { - const entryTitleText = await cell.getVisibleText(); + const title = await cell.getVisibleText(); const parentRow = await cell.findByXpath('ancestor::tr'); - const author = await parentRow.findByCssSelector( + const authorElm = await parentRow.findByCssSelector( testSubjSelector(ui.pages.kbManagementTab.tableAuthorCell) ); - const authorText = await author.getVisibleText(); + const author = await authorElm.getVisibleText(); const rowText = (await parentRow.getVisibleText()).split('\n'); - return { rowText, authorText, entryTitleText }; + return { rowText, author, title }; }) ); log.debug(`Found ${rows.length} rows in the KB management table: ${JSON.stringify(rows)}`); - return rows.filter(({ entryTitleText }) => entryTitleText === 'my_fav_color'); + return rows.filter(({ title }) => title === 'Favourite color'); } before(async () => { @@ -112,7 +117,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte it('shows two different authors', async () => { const entries = await getKnowledgeBaseEntries(); - expect(entries.map(({ authorText }) => authorText)).to.eql(['secondary_editor', 'editor']); + expect(entries.map(({ author }) => author)).to.eql(['secondary_editor', 'editor']); }); }); });