Comparing version 0.3.3 to 0.3.4
@@ -10,3 +10,3 @@ import { Observable } from 'rxjs'; | ||
entity: string; | ||
type: "accountName"; | ||
type: string; | ||
startIndex: number; | ||
@@ -18,5 +18,5 @@ endIndex: number; | ||
query: string; | ||
topScoringIntent: LuisIntent; | ||
intents: LuisIntent[]; | ||
entities: LuisEntity[]; | ||
topScoringIntent?: LuisIntent; | ||
intents?: LuisIntent[]; | ||
entities?: LuisEntity[]; | ||
} | ||
@@ -23,0 +23,0 @@ export interface LuisRule<S extends ITextInput> { |
@@ -84,3 +84,5 @@ "use strict"; | ||
}; | ||
this.url = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" + id + "?subscription-key=" + key + "&q="; | ||
this.url = | ||
id === 'id' && key === 'key' ? 'testData' : | ||
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" + id + "?subscription-key=" + key + "&q="; | ||
} | ||
@@ -93,5 +95,7 @@ LUIS.prototype.call = function (utterance) { | ||
? rxjs_1.Observable.of(response).do(function (_) { return console.log("from cache!!"); }) | ||
: rxjs_1.Observable.ajax.get(_this.url + utterance) | ||
.do(function (ajaxResponse) { return console.log("LUIS response!", ajaxResponse); }) | ||
.map(function (ajaxResponse) { return ajaxResponse.response; }) | ||
: (_this.url === 'testData' | ||
? rxjs_1.Observable.of(_this.testData[utterance]) | ||
: rxjs_1.Observable.ajax.get(_this.url + utterance) | ||
.do(function (ajaxResponse) { return console.log("LUIS response!", ajaxResponse); }) | ||
.map(function (ajaxResponse) { return ajaxResponse.response; })) | ||
.do(function (luisResponse) { return _this.cache[utterance] = luisResponse; }); }); | ||
@@ -98,0 +102,0 @@ }; |
{ | ||
"name": "prague", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "experimental Rx-based bot technology", | ||
@@ -5,0 +5,0 @@ "main": "dist/prague.js", |
@@ -14,3 +14,3 @@ import { Observable } from 'rxjs'; | ||
entity: string; | ||
type: "accountName"; | ||
type: string; | ||
startIndex: number; | ||
@@ -23,5 +23,5 @@ endIndex: number; | ||
query: string; | ||
topScoringIntent: LuisIntent; | ||
intents: LuisIntent[]; | ||
entities: LuisEntity[]; | ||
topScoringIntent?: LuisIntent; | ||
intents?: LuisIntent[]; | ||
entities?: LuisEntity[]; | ||
} | ||
@@ -38,2 +38,6 @@ | ||
interface TestData { | ||
[utterance: string]: LuisResponse; | ||
} | ||
export class LUIS<S extends ITextInput> { | ||
@@ -44,6 +48,8 @@ private cache: LuisCache = {}; | ||
constructor(id: string, key: string, private scoreThreshold = 0.5) { | ||
this.url = `https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/${id}?subscription-key=${key}&q=`; | ||
this.url = | ||
id === 'id' && key === 'key' ? 'testData' : | ||
`https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/${id}?subscription-key=${key}&q=`; | ||
} | ||
private testData = { | ||
private testData: TestData = { | ||
"Wagon Wheel": { | ||
@@ -129,5 +135,8 @@ query: "Wagon Wheel", | ||
? Observable.of(response).do(_ => console.log("from cache!!")) | ||
: Observable.ajax.get(this.url + utterance) | ||
.do(ajaxResponse => console.log("LUIS response!", ajaxResponse)) | ||
.map(ajaxResponse => ajaxResponse.response as LuisResponse) | ||
: (this.url === 'testData' | ||
? Observable.of(this.testData[utterance]) | ||
: Observable.ajax.get(this.url + utterance) | ||
.do(ajaxResponse => console.log("LUIS response!", ajaxResponse)) | ||
.map(ajaxResponse => ajaxResponse.response as LuisResponse) | ||
) | ||
.do(luisResponse => this.cache[utterance] = luisResponse) | ||
@@ -134,0 +143,0 @@ ) |
Sorry, the diff of this file is not supported yet
68785
1249