public async Task AnalyzeConversationOrchestrationPredictionLuisAsync() { ConversationAnalysisClient client = Client; Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync( "Reserve a table for 2 at the Italian restaurant.", TestEnvironment.OrchestrationProject); CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult; var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction; string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.Luis) { LuisTargetIntentResult luisTargetIntentResult = targetIntentResult as LuisTargetIntentResult; BinaryData luisResponse = luisTargetIntentResult.Result; Console.WriteLine($"LUIS Response: {luisResponse.ToString()}"); } Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Luis)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("RestaurantIntent")); }
public void AnalyzeConversationOrchestrationPredictionLuis() { ConversationAnalysisClient client = Client; Response <AnalyzeConversationResult> response = client.AnalyzeConversation( "Book me flight from London to Paris", TestEnvironment.OrchestrationProject); OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionLuis string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.Luis) { LuisTargetIntentResult luisTargetIntentResult = targetIntentResult as LuisTargetIntentResult; BinaryData luisResponse = luisTargetIntentResult.Result; Console.WriteLine($"LUIS Response: {luisResponse.ToString()}"); } #endregion Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Luis)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("FlightBooking")); }
public async Task AnalyzeConversationOrchestrationPredictionQuestionAnsweringAsync() { ConversationAnalysisClient client = Client; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionAsync #if SNIPPET ConversationsProject orchestrationProject = new ConversationsProject("DomainOrchestrator", "production"); Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync( "How are you?", orchestrationProject); #else Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync( "How are you?", TestEnvironment.OrchestrationProject); #endif CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult; var orchestratorPrediction = customConversationalTaskResult.Result.Prediction as OrchestratorPrediction; #endregion string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetProjectKind == TargetProjectKind.QuestionAnswering) { Console.WriteLine($"Top intent: {respondingProjectName}"); QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult; BinaryData questionAnsweringResponse = qnaTargetIntentResult.Result; Console.WriteLine($"Qustion Answering Response: {questionAnsweringResponse.ToString()}"); } Assert.That(targetIntentResult.TargetProjectKind, Is.EqualTo(TargetProjectKind.QuestionAnswering)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("ChitChat-QnA")); }
public void AnalyzeConversationOrchestrationPredictionConversation() { ConversationAnalysisClient client = Client; Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation( "Send an email to Carol about the tomorrow's demo", TestEnvironment.OrchestrationProject); CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult; var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionConversation string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.Conversation) { ConversationTargetIntentResult cluTargetIntentResult = targetIntentResult as ConversationTargetIntentResult; ConversationResult conversationResult = cluTargetIntentResult.Result; ConversationPrediction conversationPrediction = conversationResult.Prediction; Console.WriteLine($"Top Intent: {conversationResult.Prediction.TopIntent}"); Console.WriteLine($"Intents:"); foreach (ConversationIntent intent in conversationPrediction.Intents) { Console.WriteLine($"Intent Category: {intent.Category}"); Console.WriteLine($"Confidence: {intent.Confidence}"); Console.WriteLine(); } Console.WriteLine($"Entities:"); foreach (ConversationEntity entity in conversationPrediction.Entities) { Console.WriteLine($"Entity Text: {entity.Text}"); Console.WriteLine($"Entity Category: {entity.Category}"); Console.WriteLine($"Confidence: {entity.Confidence}"); Console.WriteLine($"Starting Position: {entity.Offset}"); Console.WriteLine($"Length: {entity.Length}"); Console.WriteLine(); foreach (BaseResolution resolution in entity.Resolutions) { if (resolution is DateTimeResolution dateTimeResolution) { Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}"); Console.WriteLine($"Timex: {dateTimeResolution.Timex}"); Console.WriteLine($"Value: {dateTimeResolution.Value}"); Console.WriteLine(); } } } } #endregion Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Conversation)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("EmailIntent")); }
public void AnalyzeConversationOrchestrationPredictionConversation() { ConversationAnalysisClient client = Client; Response <AnalyzeConversationResult> response = client.AnalyzeConversation( "We'll have 2 plates of seared salmon nigiri.", TestEnvironment.OrchestrationProject); OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionConversation string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.Conversation) { ConversationTargetIntentResult cluTargetIntentResult = targetIntentResult as ConversationTargetIntentResult; ConversationResult conversationResult = cluTargetIntentResult.Result; ConversationPrediction conversationPrediction = conversationResult.Prediction; if (!String.IsNullOrEmpty(conversationResult.DetectedLanguage)) { Console.WriteLine($"Detected Language: {conversationResult.DetectedLanguage}"); } Console.WriteLine($"Top Intent: {conversationResult.Prediction.TopIntent}"); Console.WriteLine($"Intents:"); foreach (ConversationIntent intent in conversationPrediction.Intents) { Console.WriteLine($"Intent Category: {intent.Category}"); Console.WriteLine($"Confidence Score: {intent.ConfidenceScore}"); Console.WriteLine(); } Console.WriteLine($"Entities:"); foreach (ConversationEntity entitiy in conversationPrediction.Entities) { Console.WriteLine($"Entity Text: {entitiy.Text}"); Console.WriteLine($"Entity Category: {entitiy.Category}"); Console.WriteLine($"Confidence Score: {entitiy.ConfidenceScore}"); Console.WriteLine($"Starting Position: {entitiy.Offset}"); Console.WriteLine($"Length: {entitiy.Length}"); Console.WriteLine(); } } #endregion Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Conversation)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("SushiOrder")); }
public void AnalyzeConversationOrchestrationPredictionQuestionAnswering() { ConversationAnalysisClient client = Client; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPrediction #if SNIPPET ConversationsProject orchestrationProject = new ConversationsProject("DomainOrchestrator", "production"); Response <AnalyzeConversationResult> response = client.AnalyzeConversation( "How are you?", orchestrationProject); #else Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation( "How are you?", TestEnvironment.OrchestrationProject); #endif CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult; var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction; #endregion #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionQnA string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering) { Console.WriteLine($"Top intent: {respondingProjectName}"); QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult; KnowledgeBaseAnswers qnaAnswers = qnaTargetIntentResult.Result; Console.WriteLine("Answers: \n"); foreach (KnowledgeBaseAnswer answer in qnaAnswers.Answers) { Console.WriteLine($"Answer: {answer.Answer}"); Console.WriteLine($"Confidence: {answer.Confidence}"); Console.WriteLine($"Source: {answer.Source}"); Console.WriteLine(); } } #endregion Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.QuestionAnswering)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("ChitChat-QnA")); }
public void AnalyzeConversationOrchestrationPredictionQuestionAnswering() { ConversationAnalysisClient client = Client; #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPrediction #if SNIPPET ConversationsProject orchestrationProject = new ConversationsProject("DomainOrchestrator", "production"); Response <AnalyzeConversationResult> response = client.AnalyzeConversation( "Where are the calories per recipe?", orchestrationProject); #else Response <AnalyzeConversationResult> response = client.AnalyzeConversation( "Where are the calories per recipe?", TestEnvironment.OrchestrationProject); #endif OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction; #endregion #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionQnA string respondingProjectName = orchestratorPrediction.TopIntent; TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName]; if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering) { QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult; KnowledgeBaseAnswers qnaAnswers = qnaTargetIntentResult.Result; Console.WriteLine("Answers: \n"); foreach (KnowledgeBaseAnswer answer in qnaAnswers.Answers) { Console.WriteLine($"Answer: {answer.Answer}"); Console.WriteLine($"Confidence Score: {answer.ConfidenceScore}"); Console.WriteLine($"Source: {answer.Source}"); Console.WriteLine(); } } #endregion Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.QuestionAnswering)); Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("SushiMaking")); }