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 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")); }