diff --git a/packages/ai/integration/constants.ts b/packages/ai/integration/constants.ts index 3e84f360a03..c1bf74770c9 100644 --- a/packages/ai/integration/constants.ts +++ b/packages/ai/integration/constants.ts @@ -94,6 +94,22 @@ export const liveTestConfigs: readonly TestConfig[] = backends.flatMap( } ); +/** + * Test configurations used for server prompt templates integration tests. + * Server prompt templates don't define the model name from the client, so these test configs + * do not define a model string. + * These tests should only run once per backend, rather than once per backend *per model*. + */ +export const promptTemplatesTestConfigs: readonly TestConfig[] = + backends.flatMap(backend => { + const ai = getAI(app, { backend }); + return { + ai, + model: '', // Unused by prompt templates tests + toString: () => formatConfigAsString({ ai, model: '' }).trim() + }; + }); + export const TINY_IMG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='; export const IMAGE_MIME_TYPE = 'image/png'; diff --git a/packages/ai/integration/prompt-templates.test.ts b/packages/ai/integration/prompt-templates.test.ts index 3a7f9038561..a73f17eee27 100644 --- a/packages/ai/integration/prompt-templates.test.ts +++ b/packages/ai/integration/prompt-templates.test.ts @@ -21,8 +21,7 @@ import { getTemplateGenerativeModel, getTemplateImagenModel } from '../src'; -import { testConfigs } from './constants'; -import { STAGING_URL } from '../src/constants'; +import { promptTemplatesTestConfigs } from './constants'; const templateBackendSuffix = ( backendType: BackendType @@ -31,13 +30,11 @@ const templateBackendSuffix = ( describe('Prompt templates', function () { this.timeout(20_000); - testConfigs.forEach(testConfig => { + promptTemplatesTestConfigs.forEach(testConfig => { describe(`${testConfig.toString()}`, () => { describe('Generative Model', () => { it('successfully generates content', async () => { - const model = getTemplateGenerativeModel(testConfig.ai, { - baseUrl: STAGING_URL - }); + const model = getTemplateGenerativeModel(testConfig.ai); const { response } = await model.generateContent( `sassy-greeting-${templateBackendSuffix( testConfig.ai.backend.backendType @@ -49,16 +46,14 @@ describe('Prompt templates', function () { }); describe('Imagen model', async () => { it('successfully generates images', async () => { - const model = getTemplateImagenModel(testConfig.ai, { - baseUrl: STAGING_URL - }); + const model = getTemplateImagenModel(testConfig.ai); const { images } = await model.generateImages( `portrait-${templateBackendSuffix( testConfig.ai.backend.backendType )}`, { animal: 'Rhino' } ); - expect(images.length).to.equal(2); // We ask for two images in the prompt template + expect(images.length).to.equal(1); // The template is configured to generate one image. }); }); });