public async Task ShouldAddLabelledExample() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { // Add simple entity name if not already exists if (await client.GetEntityByNameAsync("name", appId, appVersion) == null) { await client.AddEntityAsync("name", appId, appVersion); } if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null) { await client.AddIntentAsync(IntentName, appId, appVersion); } var labeledExample = new Example() { Text = "Who is Test User!", IntentName = IntentName, EntityLabels = new List <EntityLabel> { new EntityLabel { EntityName = "name", StartCharIndex = 7, EndCharIndex = 15 } } }; var utterance = await client.AddExampleAsync(appId, appVersion, labeledExample); Assert.IsNotNull(utterance); } }
public async Task ShouldDeleteIntentAndUtterancesTest() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null) { await client.AddIntentAsync(IntentName, appId, appVersion); } // Add example for the intent var exampleAdded = await client.AddExampleAsync(appId, appVersion, new Example() { IntentName = IntentName, Text = "This is sample utterance" }); if (!string.IsNullOrEmpty(exampleAdded?.UtteranceText)) { var intent = await client.GetIntentByNameAsync(IntentName, appId, appVersion); await client.DeleteIntentAsync(intent.Id, appId, appVersion, true); // TODO : once the get exampleById available, get the exmaple and assert for null intent = await client.GetIntentByIdAsync(intent.Id, appId, appVersion); Assert.IsNull(intent); } } }
public async Task ShouldAddExample() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); string intentTestId = null; var intentTest = await client.GetIntentByNameAsync("IntentTest", _appId, "1.0"); if (intentTest != null) { intentTestId = intentTest.Id; } else { intentTestId = await client.AddIntentAsync("IntentTest", _appId, "1.0"); } var example = new Example { Text = "Hello World!", IntentName = "IntentTest" }; var utterance = await client.AddExampleAsync(_appId, "1.0", example); Assert.IsNotNull(utterance); }
public async Task ShouldAddExample() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { string intentTestId = null; var intentTest = await client.GetIntentByNameAsync(IntentName, appId, appVersion); if (intentTest != null) { intentTestId = intentTest.Id; } else { intentTestId = await client.AddIntentAsync(IntentName, appId, appVersion); } var example = new Example { Text = "Hello World!", IntentName = IntentName }; var utterance = await client.AddExampleAsync(appId, appVersion, example); Assert.IsNotNull(utterance); } }
public async Task ShouldSendPublishRequest() { IEnumerable <Training> trainingList; using (var client = new LuisProgClient(SubscriptionKey, Region)) { await client.AddIntentAsync("IntentTest", appId, appVersion); await client.AddExampleAsync(appId, appVersion, new Example { Text = "Hello World!", IntentName = "IntentTest" }); await client.TrainAsync(appId, appVersion); do { trainingList = await client.GetTrainingStatusListAsync(appId, appVersion); }while (!trainingList.All(x => x.Details.Status.Equals("Success"))); var publish = await client.PublishAsync(appId, appVersion, false, "westus"); Assert.IsNotNull(publish); } }
public async Task Learn(string message, string intent) { var example = CreateExample(message, intent); var app = await luisProgClient.GetAppByNameAsync(ConfigurationManager.AppSettings.Get("LuisAppName")); await luisProgClient.AddExampleAsync(app.Id, app.Endpoints.Production.VersionId, example); await luisProgClient.TrainAsync(app.Id, app.Endpoints.Production.VersionId); await VerifyStatusTraining(luisProgClient, app); await luisProgClient.PublishAsync(app.Id, app.Endpoints.Production.VersionId, false, "westus"); }
public async Task ShouldThrowExceptionOnAddExampleWhenIntentTestNotExists() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var intentTest = await client.GetIntentByNameAsync("IntentTest", _appId, "1.0"); if (intentTest != null) { await client.DeleteIntentAsync(intentTest.Id, _appId, "1.0"); } var example = new Example { Text = "Hello World!", IntentName = "IntentTest" }; var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.AddExampleAsync(_appId, "1.0", example)); Assert.AreEqual(ex.Message, "The intent classifier IntentTest does not exist in the selected application"); }
public static async Task Learn(IConfiguration configuration, string message, string intent) { using (var client = new LuisProgClient(configuration["LUIS:AuthoringKey"], Regions.WestUS)) { var app = await client.GetAppByNameAsync("Hotel"); await client.AddExampleAsync(app.Id, app.Endpoints.Production.VersionId, new Example { Text = message, IntentName = intent }); var trainingDetails = await client.TrainAndGetFinalStatusAsync(app.Id, app.Endpoints.Production.VersionId); if (trainingDetails.Status.Equals("Success")) { await client.PublishAsync(app.Id, app.Endpoints.Production.VersionId, false, "westus"); await client.PublishAsync(app.Id, app.Endpoints.Production.VersionId, false, "westcentralus"); } } }
public async Task Learn(string message, string intent) { IEnumerable <Training> trainingList; var client = new LuisProgClient("{YourSubscriptionKey}", Location.WestUS); var app = await client.GetAppByNameAsync("Hotel"); await client.AddExampleAsync(app.Id, app.Endpoints.Production.VersionId, new Example { Text = message, IntentName = intent }); await client.TrainAsync(app.Id, app.Endpoints.Production.VersionId); do { trainingList = await client.GetTrainingStatusListAsync(app.Id, app.Endpoints.Production.VersionId); }while (!trainingList.All(x => x.Details.Status.Equals("Success"))); await client.PublishAsync(app.Id, app.Endpoints.Production.VersionId, false, "westus"); await client.PublishAsync(app.Id, app.Endpoints.Production.VersionId, false, "westcentralus"); }
public async Task ShouldThrowExceptionOnAddExampleWhenIntentTestNotExists() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var intentTest = await client.GetIntentByNameAsync(IntentName, appId, appVersion); if (intentTest != null) { await client.DeleteIntentAsync(intentTest.Id, appId, appVersion); } var example = new Example { Text = "Hello World!", IntentName = IntentName }; var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.AddExampleAsync(appId, appVersion, example)); Assert.AreEqual(ex.Message, "BadArgument - The intent classifier IntentTest does not exist in the application version."); } }
public async Task ShouldSendPublishRequest() { IEnumerable <Training> trainingList; var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); await client.AddIntentAsync("IntentTest", _appId, "1.0"); await client.AddExampleAsync(_appId, "1.0", new Example { Text = "Hello World!", IntentName = "IntentTest" }); await client.TrainAsync(_appId, "1.0"); do { trainingList = await client.GetTrainingStatusListAsync(_appId, "1.0"); }while (!trainingList.All(x => x.Details.Status.Equals("Success"))); var publish = await client.PublishAsync(_appId, "1.0", false, "westus"); Assert.IsNotNull(publish); }