public static async Task <PredictionResponse> GetObjectResult(string input) { var credentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.ApiKeyServiceClientCredentials(predictionKey); var runtimeClient = new LUISRuntimeClient(credentials) { Endpoint = predictionEndpoint }; var request = new PredictionRequest { Query = input }; var prediction = await runtimeClient.Prediction.GetSlotPredictionAsync(appId, "Production", request); return(prediction); }
public static async Task <string> GetResult(string input) { var credentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.ApiKeyServiceClientCredentials(predictionKey); var runtimeClient = new LUISRuntimeClient(credentials) { Endpoint = predictionEndpoint }; var request = new PredictionRequest { Query = input }; var prediction = await runtimeClient.Prediction.GetSlotPredictionAsync(appId, "Production", request); var result = JsonConvert.SerializeObject(prediction, Formatting.Indented); return(result); }
async static Task RunQuickstart() { // Generate the credentials and create the authoring client. var authoring_credentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.ApiKeyServiceClientCredentials(authoring_key); var authoring_client = new LUISAuthoringClient(authoring_credentials, new System.Net.Http.DelegatingHandler[] { }) { Endpoint = authoring_endpoint }; // Generate the credentials and create the runtime client. var runtime_credentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.ApiKeyServiceClientCredentials(runtime_key); var runtime_client = new LUISRuntimeClient(runtime_credentials, new System.Net.Http.DelegatingHandler[] { }) { Endpoint = runtime_endpoint }; Console.WriteLine("Creating application..."); var app = await CreateApplication(authoring_client); Console.WriteLine(); /* We skip adding entities, intents, and utterances because the * predict method will not find the app anyway. */ Console.WriteLine("Training application..."); await Train_App(authoring_client, app); Console.WriteLine("Waiting 30 seconds for training to complete..."); System.Threading.Thread.Sleep(30000); Console.WriteLine(); Console.WriteLine("Publishing application..."); await Publish_App(authoring_client, app); Console.WriteLine(); Console.WriteLine("Querying application..."); /* It doesn't matter what query we send because the predict method * will not find the app anyway. */ await Query_App(runtime_client, app, "test"); Console.WriteLine(); Console.WriteLine("Deleting application..."); await Delete_App(authoring_client, app); }
public LuisClient( string authoringKey, string authoringRegion, string endpointKey, string endpointRegion, AzureSubscriptionInfo azureSubscriptionInfo, bool isStaging) { this.IsStaging = isStaging; var endpointOrAuthoringKey = endpointKey ?? authoringKey ?? throw new ArgumentException($"Must specify either '{nameof(authoringKey)}' or '{nameof(endpointKey)}'."); this.EndpointRegion = endpointRegion ?? authoringRegion ?? throw new ArgumentException($"Must specify either '{nameof(authoringRegion)}' or '{nameof(endpointRegion)}'."); this.AzureSubscriptionInfo = azureSubscriptionInfo; this.AuthoringKey = authoringKey; var endpointCredentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.ApiKeyServiceClientCredentials(endpointOrAuthoringKey); this.RuntimeClient = new LUISRuntimeClient(endpointCredentials) { Endpoint = $"{Protocol}{this.EndpointRegion}{Domain}", }; this.LazyAuthoringClient = new Lazy <LUISAuthoringClient>(() => { if (authoringKey == null || authoringRegion == null) { throw new InvalidOperationException("Must provide authoring key and region to perform authoring operations."); } var authoringCredentials = new Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.ApiKeyServiceClientCredentials(authoringKey); return(new LUISAuthoringClient(authoringCredentials) { Endpoint = $"{Protocol}{authoringRegion}{Domain}", }); }); this.LazySpeechConfig = new Lazy <SpeechConfig>(() => SpeechConfig.FromSubscription(endpointKey, endpointRegion)); }