UNPKG

intellinode

Version:

Create AI agents using the latest models, including ChatGPT, Llama, Diffusion, Cohere, Gemini, and Hugging Face.

71 lines (63 loc) 1.79 kB
const assert = require('assert'); const GoogleAIWrapper = require('../../wrappers/GoogleAIWrapper'); const config = require('../../config.json'); function testGoogleAIWrapper() { const apiKey = 'your-api-key'; const googleAIWrapper = new GoogleAIWrapper(apiKey); assert.strictEqual( googleAIWrapper.API_KEY, apiKey, 'API key should be set' ); assert.ok( googleAIWrapper.client, 'client should be created' ); // Test httpClient configuration const expectedBaseURL = config.url.google.base.replace( '{1}', config.url.google.speech.prefix ); const expectedContentType = 'application/json; charset=utf-8'; assert.strictEqual( googleAIWrapper.client.baseURL, expectedBaseURL, 'httpClient baseURL should be set correctly' ); assert.strictEqual( googleAIWrapper.client.defaultHeaders['Content-Type'], expectedContentType, 'httpClient Content-Type header should be set correctly' ); assert.strictEqual( googleAIWrapper.client.defaultHeaders['X-Goog-Api-Key'], apiKey, 'httpClient X-Goog-Api-Key header should be set correctly' ); // Test getSynthesizeInput() method const params = { text: 'Hello world', languageCode: 'en-US', name: 'en-US-Wavenet-A', ssmlGender: 'MALE', }; const expectedModelInput = JSON.stringify({ input: { text: params.text, }, voice: { languageCode: params.languageCode, name: params.name, ssmlGender: params.ssmlGender, }, audioConfig: { audioEncoding: 'MP3', }, }); assert.strictEqual( googleAIWrapper.getSynthesizeInput(params), expectedModelInput, 'getSynthesizeInput() should return the correct model input as a JSON string' ); } module.exports = testGoogleAIWrapper;