kibana/packages/kbn-gen-ai-functional-testing
Pierre Gayvallet 14ad13b6a3
Add base FTR test coverage for inference APIs (#198000)
## Summary

Part of https://github.com/elastic/kibana-team/issues/1271

This PR introduces the first set of end to end integration test for the
inference APIs, and the tooling required to do so (see issue for more
context)

- Add a dedicated pipeline for ai-infra GenAI tests. pipeline is
triggered when:
  - genAI stack connectors, or ai-infra owned code is changed
  - when the `ci:all-gen-ai-suites` label is present on a PR
  - on merge
- adapt the `ftr_configs.sh` script to load GenAI connector
configuration from vault when a specific var env is set
- create the `@kbn/gen-ai-functional-testing` package, which for now
only contains utilities to load the GenAI connector configuration in FTR
tests
- Add FTR integration tests for the `chatComplete` API of the
`inference` plugin

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-12-04 06:39:45 -06:00
..
scripts Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
src Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
.gitignore Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
index.ts Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
jest.config.js Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
kibana.jsonc Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
package.json Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
README.md Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00
tsconfig.json Add base FTR test coverage for inference APIs (#198000) 2024-12-04 06:39:45 -06:00

@kbn/gen-ai-functional-testing

Package exposing various utilities for GenAI/LLM related functional testing.

Features

LLM connectors

Utilizing LLM connectors on FTR tests can be done via the getPreconfiguredConnectorConfig and getAvailableConnectors tools.

getPreconfiguredConnectorConfig should be used to define the list of connectors when creating the FTR test's configuration.

import { getPreconfiguredConnectorConfig } from '@kbn/gen-ai-functional-testing'

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
  const xpackFunctionalConfig = {...};
  const preconfiguredConnectors = getPreconfiguredConnectorConfig();

  return {
    ...xpackFunctionalConfig.getAll(),
    kbnTestServer: {
      ...xpackFunctionalConfig.get('kbnTestServer'),
      serverArgs: [
        ...xpackFunctionalConfig.get('kbnTestServer.serverArgs'),
        `--xpack.actions.preconfigured=${JSON.stringify(preconfiguredConnectors)}`,
      ],
    },
  };
}

then the getAvailableConnectors can be used during the test suite to retrieve the list of LLM connectors.

For example to run some predefined test suite against all exposed LLM connectors:

import { getAvailableConnectors } from '@kbn/gen-ai-functional-testing';

export default function (providerContext: FtrProviderContext) {
  describe('Some GenAI FTR test suite', async () => {
    getAvailableConnectors().forEach((connector) => {
      describe(`Using connector ${connector.id}`, () => {
        myTestSuite(connector, providerContext);
      });
    });
  });
}