diff --git a/services/language_translator/v2.html b/services/language_translator/v2.html index df0d141e..a4cb07c1 100644 --- a/services/language_translator/v2.html +++ b/services/language_translator/v2.html @@ -60,6 +60,12 @@ +
+ + + +
+
-
- - - -
-
@@ -232,6 +232,7 @@ 'ja': 'Japanese', 'pt': 'Portuguese', 'ko': 'Korean', + 'nl': 'Dutch', 'zh': 'Chinese' }; @@ -288,6 +289,14 @@ return self.indexOf(value) === index; } + // Flush the cache + tor.flushModelCache = function () { + tor.models = null; + tor.domains = null; + tor.basemodels = null; + tor.custommodels = null; + tor.checkModels(); + } // Retrieve the available models from the server, if data is returned, then // can enable the dynamic selection fields. @@ -297,6 +306,10 @@ var e = $('#node-input-service-endpoint').val(); var creds = {un: u, pwd: p}; + if ($('#node-input-neural').prop('checked')) { + creds.n = 'Y'; + } + if (! $('#node-input-default-endpoint').prop('checked')) { creds.e = e; } @@ -619,6 +632,10 @@ } }); + $('#node-input-neural').change(function () { + tor.flushModelCache(); + }); + } // The dynamic nature of the selection fields in this node has caused problems. diff --git a/services/language_translator/v2.js b/services/language_translator/v2.js index faa9ea03..029dba9b 100644 --- a/services/language_translator/v2.js +++ b/services/language_translator/v2.js @@ -61,16 +61,23 @@ module.exports = function (RED) { RED.httpAdmin.get('/watson-translator/models', function (req, res) { //endpoint = sEndpoint ? sEndpoint : req.query.e; endpoint = req.query.e ? req.query.e : sEndpoint; + var lt = null, + neural = req.query.n ? true : false, + serviceSettings = { + username: sUsername ? sUsername : req.query.un, + password: sPassword ? sPassword : req.query.pwd, + version: 'v2', + url: endpoint, + headers: { + 'User-Agent': pkg.name + '-' + pkg.version + } + }; - var lt = new LanguageTranslatorV2({ - username: sUsername ? sUsername : req.query.un, - password: sPassword ? sPassword : req.query.pwd, - version: 'v2', - url: endpoint, - headers: { - 'User-Agent': pkg.name + '-' + pkg.version - } - }); + if (neural) { + serviceSettings.headers['X-Watson-Technology-Preview'] = '2017-07-01'; + } + + lt = new LanguageTranslatorV2(serviceSettings); lt.getModels({}, function (err, models) { if (err) {