diff --git a/.gitignore b/.gitignore index 940794e..65b80ef 100644 --- a/.gitignore +++ b/.gitignore @@ -286,3 +286,5 @@ __pycache__/ *.btm.cs *.odx.cs *.xsd.cs +/LUIS-CachingService/deployscript.sh +LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient.sln diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/LuisCacheClient.csproj b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/LuisCacheClient.csproj index bc63183..7f93140 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/LuisCacheClient.csproj +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/LuisCacheClient.csproj @@ -11,7 +11,7 @@ LuisCacheClient en-US UAP - 10.0.14393.0 + 10.0.16299.0 10.0.14393.0 14 512 diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/MainPage.xaml.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/MainPage.xaml.cs index 121c704..b53306c 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/MainPage.xaml.cs +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheClient/MainPage.xaml.cs @@ -22,13 +22,17 @@ namespace LuisCacheClient /// public sealed partial class MainPage : Page { - TextProcessor _processor; + static TextProcessor _processor; public MainPage() { this.InitializeComponent(); + var luisSubscriptionKey = "LUIS_KEY"; + var luisAppId = "LUIS_APP_ID"; + var mobileAppUri = "http://XXXXXXXXX.azurewebsites.net/"; - _processor = TextProcessor.Instance; + _processor = new TextProcessor(luisAppId, luisSubscriptionKey, mobileAppUri); + } private async void submitButton_Click(object sender, RoutedEventArgs e) @@ -36,11 +40,13 @@ private async void submitButton_Click(object sender, RoutedEventArgs e) ResultLabel.Text = String.Empty; FromCacheLabel.Text = String.Empty; - _processor = TextProcessor.Instance; - var result = await _processor.Predict(txtInput.Text); - if (result == null) { return; } + if (result == null) + { + ResultLabel.Text = "No results - Error or Offline - "+DateTime.Now.ToString(); + return; + } var resultLabel = result.Intent; diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/.gitignore b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/.gitignore new file mode 100644 index 0000000..ff5b00c --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/.gitignore @@ -0,0 +1,264 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# Azure Functions localsettings file +local.settings.json + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisCacheFunctions.csproj b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisCacheFunctions.csproj new file mode 100644 index 0000000..a23b3aa --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisCacheFunctions.csproj @@ -0,0 +1,26 @@ + + + netstandard2.0 + v2 + + + + + + + + + + true + + + + + PreserveNewest + + + PreserveNewest + Never + + + \ No newline at end of file diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisListApps.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisListApps.cs new file mode 100644 index 0000000..64efc5d --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisListApps.cs @@ -0,0 +1,47 @@ +using System; +using System.Net.Http; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Azure.WebJobs.Host; + +namespace LuisCacheFunctions +{ + public static class LuisListApps + { + [FunctionName("ListApps")] + public static async System.Threading.Tasks.Task RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "get")]HttpRequest req, TraceWriter log) + { + // check if there is untrained + log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); + var versionId = Environment.GetEnvironmentVariable("LuisAppId"); + var appId = Environment.GetEnvironmentVariable("LuisAppId"); + var subscriptionKey = Environment.GetEnvironmentVariable("LuisSubscriptionKey"); + var LUISendpoint = Environment.GetEnvironmentVariable("LuisApiEndpoint"); + var request = $"{LUISendpoint}/apps/?skip=0&take=100"; + + // Final LUIS Query + log.Info("LUIS query:" + request); + var httpClient = new HttpClient(); + + // LUIS HTTP CALL + httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey); + // Can add the query at the end + var response = await httpClient.GetAsync(request); + + // + if (!response.IsSuccessStatusCode) + { + // Log (HttpStatusCode.NoContent); + log.Info($"HttpStatusCode.NoContent - status : {response.StatusCode} - reason : {response.ReasonPhrase}"); + } + + var apiResult = await response.Content.ReadAsStringAsync(); + + log.Info($"Response {apiResult}"); + + return new OkObjectResult(apiResult); + } + } +} diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisProcessIntent.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisProcessIntent.cs new file mode 100644 index 0000000..086d8de --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisProcessIntent.cs @@ -0,0 +1,92 @@ +using System; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Host; +using System.Net.Http; +using Microsoft.Cognitive.LUIS; +using Newtonsoft.Json.Linq; + +using System.Net.Http.Headers; +using System.Collections.Generic; +using Microsoft.WindowsAzure.MobileServices; +using LuisCacheModel.DataModel; +using LuisCacheModel; +using Newtonsoft.Json; +//using LuisCacheModel; + +namespace LuisCacheFunctions +{ + public static class LuisProcessIntent + { + static HttpClient httpClient = new HttpClient(); + static MobileServiceClient MobileService = new MobileServiceClient(Environment.GetEnvironmentVariable("LuisCacheMobileAppUri")); + static IMobileServiceTable intentTable = MobileService.GetTable(); + + [FunctionName("LuisProcessIntent")] + public static async System.Threading.Tasks.Task RunAsync([TimerTrigger("* */1 * * * *")]TimerInfo myTimer, + TraceWriter log) + { + IList items = null; + + try + { + // Retrieve all non processed items + items = await intentTable.Where(i => i.IsProcessed == false).ToListAsync(); + } + catch(Exception ex) + { + log.Error($"Error while Retrieving all IntentItems : {ex}"); + throw ex; + } + + log.Info($"Total items to process = {items.Count}"); + + foreach (var item in items) + { + var intentId = item.Id; + + log.Info($"C# Processing Intent ID : {intentId}"); + + // Erro handling + if (item == null) + { + log.Info($"No itent item retrieved (null) - {intentId}"); + return; + } + + // Ensure item require procesing otherwise skip it + if (item.IsProcessed == true) + { + log.Info($" ItemItemd with if {intentId} has already been processed {item.IsProcessed} - will be skipped"); + return; + } + + // Calling Luis + var appId = Environment.GetEnvironmentVariable("LuisAppId"); + var subscriptionKey = Environment.GetEnvironmentVariable("LuisSubscriptionKey"); + bool isPreview = true; + + var client = new LuisClient(appId, subscriptionKey, isPreview); + LuisResult res = await client.Predict(item.Utterance); + log.Info($"Luis result : {res.DialogResponse}"); + var processingResult = new ProcessingResult(); + + List entitiesNames = new List(); + var entities = res.GetAllEntities(); + foreach (Entity entity in entities) + { + processingResult.Entities.Add(entity.Name, entity.Value); + } + + processingResult.Confidence = res.TopScoringIntent.Score; + processingResult.Intent = res.TopScoringIntent.Name; + processingResult.IsFromCache = false; + + item.Intent = processingResult.Intent; + item.JsonEntities = JsonConvert.SerializeObject(processingResult.Entities); + item.IsProcessed = true; + + await intentTable.UpdateAsync(item); + } + } + } +} diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisRetrainModel.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisRetrainModel.cs new file mode 100644 index 0000000..7be8fcb --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/LuisRetrainModel.cs @@ -0,0 +1,67 @@ +using System; +using System.Net.Http; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Host; + +namespace LuisCacheFunctions +{ + public static class LuisRetrainModel + { + [FunctionName("RetrainModel")] + public static async System.Threading.Tasks.Task RunAsync([TimerTrigger("0 * * */1 * *")]TimerInfo myTimer, TraceWriter log) + + { + // check if there is untrained + log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); + //var uri = "https://{location}.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/versions/{versionId}/train?" + queryString; + + var versionId = Environment.GetEnvironmentVariable("LuisAppVersion"); + var appId = Environment.GetEnvironmentVariable("LuisAppId"); + var subscriptionKey = Environment.GetEnvironmentVariable("LuisSubscriptionKey"); + var LUISendpoint = Environment.GetEnvironmentVariable("LuisApiEndpoint"); + var request = $"{LUISendpoint}/apps/{appId}/versions/{versionId}/train/?verbose=true&q="; + + // Final LUIS Query + + log.Info("LUIS query:" + request); + var httpClient = new HttpClient(); + + + // Check if model need to be updated + + + // LUIS HTTP CALL + httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey); + // Can add the query at the end + var response = await httpClient.PostAsync(request, null); + + // If LUIS error, return 204 - YOU SHOULD CHANGE THIS!!! + if (!response.IsSuccessStatusCode) + { + // Log (HttpStatusCode.NoContent); + log.Info($"HttpStatusCode.NoContent - status : {response.StatusCode} - reason : {response.ReasonPhrase}"); + } + + var apiResult = await response.Content.ReadAsStringAsync(); + + log.Info($"Response {apiResult}"); + + #region auto publish + // Model is trained above but not automatically published as this operation can cause unexpected behaviors and + // you might want to test it befor publishing + + // Uncomment the code below to enable the feature (send a post request with the following settings) + + // Body to post + // { + // "versionId": "0.1", + // "isStaging": false, + // "region": "westus" + //} + + // POST https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/publish + #endregion + + } + } +} diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/host.json b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/host.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheFunctions/host.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/LuisCacheLib.csproj b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/LuisCacheLib.csproj index 9ffa491..7ef67fc 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/LuisCacheLib.csproj +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/LuisCacheLib.csproj @@ -11,7 +11,7 @@ LuisCacheLib en-US UAP - 10.0.14393.0 + 10.0.16299.0 10.0.14393.0 14 512 diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/TextProcessor.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/TextProcessor.cs index 9881610..0092f00 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/TextProcessor.cs +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheLib/TextProcessor.cs @@ -19,44 +19,71 @@ namespace LuisCacheLib { public class TextProcessor { - public static MobileServiceClient MobileService = new MobileServiceClient("https://insertappservicename.azurewebsites.net"); - private IMobileServiceSyncTable intentTable = MobileService.GetSyncTable(); // offline sync + // TODO: Refactor to get from App Settings + string luisAppId = null; + // TODO: Refactor to get from App Settings + string luisSubscriptionKey = null; + // TODO: Refactor to get from App Settings + string mobileAppUri = null; + public MobileServiceClient MobileService { get; set; } + + private IMobileServiceSyncTable intentTable = null; // offline sync private MobileServiceCollection items; - private IMobileServiceSyncTable telemetryTable = MobileService.GetSyncTable(); + private IMobileServiceSyncTable telemetryTable = null; private MobileServiceCollection telemetryItems; private LuisClient _client; - private static TextProcessor instance = null; + //private static TextProcessor instance = null; - private TextProcessor() + public TextProcessor(string luisAppId, string luisSubscriptionKey, string mobileAppUri) //:base() { - var t = Task.Run(async () => - { - await InitLocalStoreAsync(); - }); - t.Wait(); + this.mobileAppUri = mobileAppUri; + this.luisAppId = luisAppId; + this.luisSubscriptionKey = luisSubscriptionKey; - string appId = "APP_ID"; - string subscriptionKey = "SUBSCRIPTION_KEY"; - bool preview = true; + MobileService = new MobileServiceClient(mobileAppUri); + intentTable = MobileService.GetSyncTable(); + telemetryTable = MobileService.GetSyncTable(); - _client = new LuisClient(appId, subscriptionKey, preview); - } - - public static TextProcessor Instance - { - get + try { - if (instance == null) + var t = Task.Run(async () => { - instance = new TextProcessor(); - } - return instance; + await InitLocalStoreAsync(); + }); + t.Wait(); + } + // Case of offline start + // TODO imporve error handling + catch(Exception ex) + { + Debug.WriteLine(ex); } + + bool preview = true; + + _client = new LuisClient(luisAppId, luisSubscriptionKey, preview); + } + //private TextProcessor() + //{ + //} + + //public static TextProcessor Instance + //{ + // get + // { + // if (instance == null) + // { + // instance = new TextProcessor(); + // } + // return instance; + // } + //} + public async Task Predict(string textToPredict) { textToPredict = textToPredict.Trim(); @@ -91,7 +118,10 @@ public async Task Predict(string textToPredict) catch (MobileServiceInvalidOperationException e) { exception = e; + Debug.WriteLine(e); + throw e; } + await Track(TelemetryEvents.CACHE_MISS, textToPredict); @@ -109,7 +139,7 @@ public async Task Predict(string textToPredict) var intentItem = new IntentItem(); intentItem.Intent = temp.Intent; intentItem.Utterance = textToPredict; - + intentItem.IsProcessed = true; intentItem.JsonEntities = JsonConvert.SerializeObject(temp.Entities); // Insert into database @@ -118,11 +148,22 @@ public async Task Predict(string textToPredict) return intent; } + catch (MobileServicePushFailedException push) + { + // + Debug.WriteLine(push); + throw push; + } + // TODO: Refactor to have a better error handling catch (System.Exception e) { + // Check App ID, Luis Key , Luis URL + // Trace error Debug.WriteLine(e.Message); + Debug.WriteLine(e); } + // Save offline var offlineIntent = new IntentItem(); offlineIntent.Utterance = textToPredict; offlineIntent.IsProcessed = false; @@ -199,7 +240,7 @@ private async Task InsertIntentItem(IntentItem IntentItem) private async Task InitLocalStoreAsync() { - string databaseFilename = "localstore1.db"; + string databaseFilename = "localstoreluis.db"; if (!MobileService.SyncContext.IsInitialized) { @@ -212,7 +253,7 @@ private async Task InitLocalStoreAsync() } catch (FileNotFoundException e) { - + Debug.WriteLine("DB does not exit - " + e); } var store = new MobileServiceSQLiteStore(databaseFilename); @@ -230,12 +271,15 @@ private async Task SyncAsync() try { await MobileService.SyncContext.PushAsync(); - await intentTable.PullAsync("IntentItems", intentTable.CreateQuery()); - await telemetryTable.PullAsync("TelemetryItems", telemetryTable.CreateQuery().Take(1)); + await intentTable.PullAsync("IntentItems", intentTable.Where(i => i.IsProcessed == true )); + //await intentTable.PullAsync(null, intentTable.Where(i => i.IsProcessed == true)); + await telemetryTable.PullAsync("Telemetry", telemetryTable.Where(t => t.UserId == "1")); } + // TODO: improve error handling catch (Exception ex) { Debug.WriteLine(ex); + throw ex; } } #endregion diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/IntentController.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/IntentController.cs index 52f44cb..752caf5 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/IntentController.cs +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/IntentController.cs @@ -10,11 +10,19 @@ using LuisCacheModel; using System.Collections.Generic; using Newtonsoft.Json; +using System; +using Microsoft.WindowsAzure.Storage; +using Microsoft.WindowsAzure.Storage.Queue; +using Microsoft.Azure; +using Microsoft.ApplicationInsights; namespace KsparkAPI.Controllers { public class IntentItemController : TableController { + + TelemetryClient ai = new TelemetryClient(); + protected override void Initialize(HttpControllerContext controllerContext) { base.Initialize(controllerContext); @@ -48,26 +56,16 @@ public Task PatchIntentItem(string id, Delta patch) public async Task PostIntentItem(IntentItem item) { System.Diagnostics.Trace.TraceInformation("Positing new intent: " + item.Utterance); + + var current = await InsertAsync(item); - IntentItem current; - if (!item.IsProcessed) - { - current = await CreateIntentItem(item); - current.IsProcessed = true; - } - else - { - current = item; - } - - current = await InsertAsync(current); return CreatedAtRoute("Tables", new { id = current.Id }, current); } private async Task CreateIntentItem(IntentItem item) { - string appId = "9f25daaa-3d94-4988-b201-f10a2d41a6a5"; - string subscriptionKey = "07f77f9e723140aeb54b4ed346752851"; + string appId = Environment.GetEnvironmentVariable("LuisAppId"); + string subscriptionKey = Environment.GetEnvironmentVariable("LuisSubscriptionKey"); bool preview = true; var client = new LuisClient(appId, subscriptionKey, preview); diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/ValuesController.cs b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/ValuesController.cs deleted file mode 100644 index 4f9237e..0000000 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Controllers/ValuesController.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Web.Http; -using Microsoft.Azure.Mobile.Server.Config; - -namespace KsparkAPI.Controllers -{ - // Use the MobileAppController attribute for each ApiController you want to use - // from your mobile clients - [MobileAppController] - public class ValuesController : ApiController - { - // GET api/values - public string Get() - { - return "Hello World!"; - } - - // POST api/values - public string Post() - { - return "Hello World!"; - } - } -} diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/LuisCacheServer.csproj b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/LuisCacheServer.csproj index cd9ea58..dc91296 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/LuisCacheServer.csproj +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/LuisCacheServer.csproj @@ -1,7 +1,9 @@  + + - + Debug @@ -48,119 +50,122 @@ - ..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll + ..\..\packages\AutoMapper.5.2.0\lib\net45\AutoMapper.dll - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + ..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + ..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - ..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.4.0\lib\net45\Microsoft.AI.Agent.Intercept.dll + ..\..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.4.0\lib\net45\Microsoft.AI.Agent.Intercept.dll - - ..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.5.0\lib\net45\Microsoft.AI.DependencyCollector.dll + + ..\..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.5.1\lib\net45\Microsoft.AI.DependencyCollector.dll - - ..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.5.0\lib\net45\Microsoft.AI.PerfCounterCollector.dll + + ..\..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.5.1\lib\net45\Microsoft.AI.PerfCounterCollector.dll - - ..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.5.0\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll + + ..\..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.5.1\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll - - ..\packages\Microsoft.ApplicationInsights.Web.2.5.0\lib\net45\Microsoft.AI.Web.dll + + ..\..\packages\Microsoft.ApplicationInsights.Web.2.5.1\lib\net45\Microsoft.AI.Web.dll - - ..\packages\Microsoft.ApplicationInsights.WindowsServer.2.5.0\lib\net45\Microsoft.AI.WindowsServer.dll + + ..\..\packages\Microsoft.ApplicationInsights.WindowsServer.2.5.1\lib\net45\Microsoft.AI.WindowsServer.dll - - ..\packages\Microsoft.ApplicationInsights.2.5.0\lib\net46\Microsoft.ApplicationInsights.dll + + ..\..\packages\Microsoft.ApplicationInsights.2.5.1\lib\net46\Microsoft.ApplicationInsights.dll - ..\packages\Microsoft.ApplicationInsights.TraceListener.2.5.0\lib\net45\Microsoft.ApplicationInsights.TraceListener.dll + ..\..\packages\Microsoft.ApplicationInsights.TraceListener.2.5.0\lib\net45\Microsoft.ApplicationInsights.TraceListener.dll - ..\packages\Microsoft.AspNet.TelemetryCorrelation.1.0.0\lib\net45\Microsoft.AspNet.TelemetryCorrelation.dll + ..\..\packages\Microsoft.AspNet.TelemetryCorrelation.1.0.0\lib\net45\Microsoft.AspNet.TelemetryCorrelation.dll + + + ..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll - ..\packages\Microsoft.Azure.Mobile.Server.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.dll - ..\packages\Microsoft.Azure.Mobile.Server.Authentication.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Authentication.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Authentication.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Authentication.dll - ..\packages\Microsoft.Azure.Mobile.Server.CrossDomain.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.CrossDomain.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.CrossDomain.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.CrossDomain.dll - ..\packages\Microsoft.Azure.Mobile.Server.Entity.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Entity.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Entity.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Entity.dll - ..\packages\Microsoft.Azure.Mobile.Server.Home.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Home.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Home.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Home.dll - ..\packages\Microsoft.Azure.Mobile.Server.Notifications.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Notifications.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Notifications.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Notifications.dll - ..\packages\Microsoft.Azure.Mobile.Server.Quickstart.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Quickstart.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Quickstart.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Quickstart.dll - ..\packages\Microsoft.Azure.Mobile.Server.Tables.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Tables.dll + ..\..\packages\Microsoft.Azure.Mobile.Server.Tables.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Tables.dll - ..\packages\Microsoft.Azure.NotificationHubs.1.0.7\lib\net45-full\Microsoft.Azure.NotificationHubs.dll + ..\..\packages\Microsoft.Azure.NotificationHubs.1.0.7\lib\net45-full\Microsoft.Azure.NotificationHubs.dll - ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + ..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll - ..\packages\Microsoft.Cognitive.LUIS.2.0.2\lib\portable45-net45+win8+wpa81\Microsoft.Cognitive.LUIS.dll + ..\..\packages\Microsoft.Cognitive.LUIS.2.0.2\lib\portable45-net45+win8+wpa81\Microsoft.Cognitive.LUIS.dll - ..\packages\Microsoft.Data.Edm.5.8.1\lib\net40\Microsoft.Data.Edm.dll + ..\..\packages\Microsoft.Data.Edm.5.8.1\lib\net40\Microsoft.Data.Edm.dll - ..\packages\Microsoft.Data.OData.5.8.1\lib\net40\Microsoft.Data.OData.dll + ..\..\packages\Microsoft.Data.OData.5.8.1\lib\net40\Microsoft.Data.OData.dll - ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll + ..\..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll + ..\..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - ..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll + ..\..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll - ..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll + ..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll + + + ..\..\packages\WindowsAzure.Storage.9.1.1\lib\net45\Microsoft.WindowsAzure.Storage.dll - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\Owin.1.0\lib\net40\Owin.dll + ..\..\packages\Owin.1.0\lib\net40\Owin.dll - ..\packages\System.Diagnostics.DiagnosticSource.4.4.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + ..\..\packages\System.Diagnostics.DiagnosticSource.4.4.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - ..\packages\System.IdentityModel.Tokens.Jwt.4.0.3.308261200\lib\net45\System.IdentityModel.Tokens.Jwt.dll + ..\..\packages\System.IdentityModel.Tokens.Jwt.4.0.3.308261200\lib\net45\System.IdentityModel.Tokens.Jwt.dll - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + ..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll - ..\packages\System.Spatial.5.8.1\lib\net40\System.Spatial.dll + ..\..\packages\System.Spatial.5.8.1\lib\net40\System.Spatial.dll - ..\packages\Microsoft.AspNet.Cors.5.2.3\lib\net45\System.Web.Cors.dll + ..\..\packages\Microsoft.AspNet.Cors.5.2.3\lib\net45\System.Web.Cors.dll - - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll - @@ -171,14 +176,17 @@ + + ..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + - ..\packages\Microsoft.AspNet.WebApi.Cors.5.2.3\lib\net45\System.Web.Http.Cors.dll + ..\..\packages\Microsoft.AspNet.WebApi.Cors.5.2.3\lib\net45\System.Web.Http.Cors.dll - ..\packages\Microsoft.AspNet.WebApi.OData.5.7.0\lib\net45\System.Web.Http.OData.dll + ..\..\packages\Microsoft.AspNet.WebApi.OData.5.7.0\lib\net45\System.Web.Http.OData.dll - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + ..\..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll @@ -191,9 +199,6 @@ - - ..\packages\AutoMapper.5.2.0\lib\net40\AutoMapper.Net4.dll - @@ -201,7 +206,6 @@ - @@ -209,7 +213,9 @@ - + + Designer + Web.config @@ -225,8 +231,11 @@ PreserveNewest - + + Designer + + @@ -269,7 +278,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Web.config b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Web.config index 446aae0..1161717 100644 --- a/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Web.config +++ b/LUIS-CachingService/LUIS-CachingComponents/LuisCacheServer/Web.config @@ -6,13 +6,23 @@
- + - + + + + + + + + + + +