@@ -44,28 +44,24 @@ var LUISResponse = require("./luis_response");
4444 * Constructs a LUISClient with the corresponding user's App ID and Subscription Keys
4545 * Starts the prediction procedure for the user's text, and accepts a callback function
4646 *
47- * @param initData an object that has 4 propertes:
47+ * @param initData an object that has 3 propertes:
4848 * @1- appId a String containing the Application Id
4949 * @2- appKey a String containing the Subscription Key
50- * @3- preview a Boolean to choose whether to use the preview version or not
51- * @4- verbose a Boolean to choose whether to use the verbose version or not
50+ * @3- verbose a Boolean to choose whether to use the verbose version or not
5251 * @returns {{predict: predict, reply: reply} } an object containing the functions that need to be used
5352 */
5453var LUISClient = function ( initData ) {
5554 validateInitData ( initData ) ;
5655 var appId = initData . appId ;
5756 var appKey = initData . appKey ;
58- var preview = initData . preview ;
5957 var verbose = initData . verbose ;
6058 validateAppInfoParam ( appId , "Application Id" ) ;
6159 validateAppInfoParam ( appKey , "Subscription Key" ) ;
62- preview = validateBooleanParam ( preview , "Preview" ) ;
6360 verbose = validateBooleanParam ( verbose , "Verbose" ) ;
6461 const LUISURL = "api.projectoxford.ai" ;
65- const LUISPreviewURL = preview ? "/preview" : "" ;
66- const LUISPredictMask = "/luis/v1/application%s?id=%s&subscription-key=%s%s&q=%s" ;
67- const LUISReplyMask = "/luis/v1/application%s?id=%s&subscription-key=%s&contextid=%s%s&q=%s" ;
68- const LUISVerboseURL = verbose ? "&verbose=true" : "" ;
62+ const LUISPredictMask = "/luis/v2.0/apps/%s?subscription-key=%s&q=%s&verbose=%s" ;
63+ const LUISReplyMask = "/luis/v2.0/apps/%s?subscription-key=%s&q=%s&contextid=%s&verbose=%s" ;
64+ const LUISVerbose = verbose ? "true" : "false" ;
6965 return {
7066 /**
7167 * Initiates the prediction procedure
@@ -79,7 +75,7 @@ var LUISClient = function(initData) {
7975 validateResponseHandlers ( responseHandlers ) ;
8076 var LUISOptions = {
8177 hostname : LUISURL ,
82- path : util . format ( LUISPredictMask , LUISPreviewURL , appId , appKey , LUISVerboseURL , encodeURIComponent ( text ) )
78+ path : util . format ( LUISPredictMask , appId , appKey , encodeURIComponent ( text ) , LUISVerbose )
8379 } ;
8480 httpHelper ( LUISOptions , responseHandlers ) ;
8581 } ,
@@ -92,17 +88,13 @@ var LUISClient = function(initData) {
9288 * on the success or failure of the web request
9389 */
9490 reply : function ( text , LUISresponse , responseHandlers , forceSetParameterName ) {
95- //TODO: When the reply can be used in the published version this condition has to be removed
96- if ( ! preview ) {
97- throw new Error ( "Reply can only be used with the preview version" ) ;
98- }
9991 text = validateText ( text ) ;
10092 validateLUISresponse ( LUISresponse ) ;
10193 validateResponseHandlers ( responseHandlers ) ;
10294 var LUISOptions = {
10395 hostname : LUISURL ,
104- path : util . format ( LUISReplyMask , LUISPreviewURL , appId , appKey ,
105- LUISresponse . dialog . contextId , LUISVerboseURL , encodeURIComponent ( text ) )
96+ path : util . format ( LUISReplyMask , appId , appKey , encodeURIComponent ( text ) ,
97+ LUISresponse . dialog . contextId , LUISVerbose )
10698 } ;
10799 if ( forceSetParameterName !== null && typeof forceSetParameterName === "string" ) {
108100 LUISOptions . path += util . format ( "&forceset=%s" , forceSetParameterName ) ;
@@ -143,8 +135,7 @@ var httpHelper = function (LUISOptions, responseHandlers) {
143135 * @param initData an object that has 4 propertes:
144136 * @1- appId a String containing the Application Id
145137 * @2- appKey a String containing the Subscription Key
146- * @3- preview a Boolean to choose whether to use the preview version or not
147- * @4- verbose a Boolean to choose whether to use the verbose version or not
138+ * @3- verbose a Boolean to choose whether to use the verbose version or not
148139 */
149140var validateInitData = function ( initData ) {
150141 if ( initData === null || typeof initData === "undefined" ) {
@@ -212,7 +203,7 @@ var validateStringParam = function (param, paramName) {
212203 */
213204var validateBooleanParam = function ( param , paramName ) {
214205 if ( typeof param === "undefined" || param === null ) {
215- param = false ;
206+ param = true ;
216207 }
217208 if ( typeof param !== "boolean" ) {
218209 throw new Error ( paramName + " flag is not boolean" ) ;
0 commit comments