public async Task ExecutePersonalityChatTests()
        {
            string userQuery        = "test query aswedff";
            string expectedResponse = "test response";
            PersonalityChatOptions personalityChatOptions = new PersonalityChatOptions();

            PersonalityChatService personalityChatService = new PersonalityChatService(personalityChatOptions, new HttpClient());

            PersonalityChatResults personalityChatResults = await personalityChatService.QueryServiceAsync(userQuery);

            string topResponse = personalityChatResults?.ScenarioList?.FirstOrDefault()?.Responses?.FirstOrDefault();

            Assert.AreEqual(expectedResponse, topResponse);
        }
Beispiel #2
0
        public virtual string GetResponse(PersonalityChatResults personalityChatResults)
        {
            var matchedScenarios = personalityChatResults?.ScenarioList;

            string response = string.Empty;

            if (matchedScenarios != null)
            {
                var topScenario = matchedScenarios.FirstOrDefault();

                if (topScenario?.Responses != null && topScenario.Score > this.personalityChatMiddlewareOptions.ScoreThreshold && topScenario.Responses.Count > 0)
                {
                    Random randomGenerator = new Random();
                    int    randomIndex     = randomGenerator.Next(topScenario.Responses.Count);

                    response = topScenario.Responses[randomIndex];
                }
            }

            return(response);
        }