public DashboardController(IErrorService errorService,
                            IBotService botService,
                            IQnAService qnaService) : base(errorService)
 {
     _botService = botService;
     _qnaService = qnaService;
 }
예제 #2
0
        public static async Task Run([ServiceBusTrigger("myqueue", Connection = "ServiceBusConnectionString")] string htmlText, ILogger log,
                                     [Inject] ILUISService ILUISService,
                                     [Inject] IQnAService IQnAService,
                                     [Inject] ITextAnalyticsService ITextAnalyticsService,
                                     [Inject] IQueueService IQueueService)
        {
            var method = "Main";

            log.LogInformation(string.Format("{0} - {1}", method, "IN"));

            if (string.IsNullOrWhiteSpace(htmlText))
            {
                throw new ArgumentNullException("You need to provide a text to test!");
            }
            var sanitizedText = HelperMethods.HtmlToPlainText(htmlText);

            log.LogInformation(string.Format("{0} - {1}", method, "Extracting information from LUIS."));
            var result = await ILUISService.ExtractEntitiesFromLUIS(sanitizedText);

            if (result.TopScoringIntent.Intent.Equals("FAQ"))
            {
                log.LogInformation(string.Format("{0} - {1}", method, "Getting FAQs Answer."));
                var response = IQnAService.CheckQnAMakerForResponse(sanitizedText);
                IQueueService.InsertAnswerIntoCRM(response);
            }
            else
            {
                log.LogInformation(string.Format("{0} - {1}", method, "Getting Keywords and Sentiment."));
                var response = ITextAnalyticsService.ExtractKeywordsAndSentimentFromTextAnalytics(sanitizedText);
                IQueueService.InsertKeywordAndSentimentoIntoCRM(response);
            }
        }
        public static async Task <bool> ActiveLearnAsync(
            this IQnAService service,
            string userId,
            string userQuestion,
            string kbQuestion,
            string kbAnswer,
            string knowledgebaseId)
        {
            QnAMakerTrainingRequestBody postBody;
            string subscriptionKey;
            string serviceKnowledgebaseId;
            var    uri = service.BuildFeedbackRequest(
                userId,
                userQuestion,
                kbQuestion,
                kbAnswer,
                out postBody,
                out subscriptionKey,
                out serviceKnowledgebaseId);

            if (serviceKnowledgebaseId.Equals(knowledgebaseId))
            {
                return(await service.ActiveLearnAsync(uri, postBody, subscriptionKey));
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Query the QnA service using this text.
        /// </summary>
        /// <param name="service">QnA service.</param>
        /// <param name="text">The query text.</param>
        /// <returns>The QnA result.</returns>
        public static async Task <QnAMakerResults> QueryServiceAsync(this IQnAService service, string text)
        {
            QnAMakerRequestBody postBody;
            string authKey = "e00dabb2-8106-4ce0-9cd2-2e2bc6fa8492";
            var    uri     = service.BuildRequest(text, out postBody, out authKey);

            return(await service.QueryServiceAsync(uri, postBody, authKey));
        }
예제 #5
0
        /// <summary>
        /// Query the QnA service using this text.
        /// </summary>
        /// <param name="service">QnA service.</param>
        /// <param name="text">The query text.</param>
        /// <param name="strictFilters">Strict filters</param>
        /// <returns>The QnA result.</returns>
        public static async Task <QnAMakerResults> QueryServiceAsync(this IQnAService service, string text, List <Metadata> strictFilters = null)
        {
            QnAMakerRequestBody postBody;
            string authKey;
            var    uri = service.BuildRequest(text, strictFilters, out postBody, out authKey);

            return(await service.QueryServiceAsync(uri, postBody, authKey));
        }
        /// <summary>
        /// Query the QnA service using this text.
        /// </summary>
        /// <param name="service">QnA service.</param>
        /// <param name="text">The query text.</param>
        /// <returns>The QnA result.</returns>
        public static async Task <QnAMakerResults> QueryServiceAsync(this IQnAService service, string text)
        {
            QnAMakerRequestBody postBody;
            string subscriptionKey;
            var    uri = service.BuildRequest(text, out postBody, out subscriptionKey);

            return(await service.QueryServiceAsync(uri, postBody, subscriptionKey));
        }
 public QnAController(IErrorService errorService,
                      IQnAService qnaService,
                      IAIMLFileService aimlService) : base(errorService)
 {
     _qnaService  = qnaService;
     _aimlService = aimlService;
     _apiNLR      = new ApiQnaNLRService();
 }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuestionDialog"/> class.
        /// </summary>
        /// <param name="provider">Provides access to core services.</param>
        public QuestionDialog(IBotProvider provider)
        {
            provider.AssertNotNull(nameof(provider));

            QnAService = new QnAMakerService(new QnAMakerAttribute(
                                                 provider.Configuration.QnASubscriptionKey.ToUnsecureString(),
                                                 provider.Configuration.QnAKnowledgebaseId,
                                                 "default message",
                                                 0.6));
        }
 public LandingPageController(IQnARepository __IQnARepository, IQnAService __IQnAService, IVideoGalleryRepository __IVideoGalleryRepository,
                              IVideoGalleryService __IVideoGalleryService, IQnAImageService __IQnAImageService, IQnAVideoService __IQnAVideoService)
 {
     _IQnARepository          = __IQnARepository;
     _IQnAService             = __IQnAService;
     _IVideoGalleryRepository = __IVideoGalleryRepository;
     _IVideoGalleryService    = __IVideoGalleryService;
     _IQnAImageService        = __IQnAImageService;
     _IQnAVideoService        = __IQnAVideoService;
 }
예제 #10
0
        public QnABot(ConversationState conversationState, UserState userState, IQnAService qnaService, ILogger <QnABot> logger, IConfiguration configuration)
            : base(conversationState, userState, new QnADialog(qnaService, configuration), logger, configuration)
        {
            welcomeMessage  = _configuration.GetValue <string>("WelcomeMessage");
            _azureAdEnabled = configuration["AzureAd:Enable"].ToLower() == "true" ? true : false;
            _connectionName = _configuration["AzureAd:ConnectionName"];
            var dialogState = _conversationState.CreateProperty <DialogState>("DialogState");

            _dialogSet = new DialogSet(dialogState);
        }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PublishKbHostedService"/> class.
 /// </summary>
 /// <param name="settings">background services settings.</param>
 /// <param name="qnAService">QnA service.</param>
 /// <param name="logger">Logger.</param>
 /// <param name="telemetryClient">Telemetry client.</param>
 public PublishKbHostedService(
     BackgroundServicesSettings settings,
     IQnAService qnAService,
     ILogger <PublishKbHostedService> logger,
     TelemetryClient telemetryClient)
 {
     this.settings        = settings ?? throw new ArgumentNullException(nameof(settings));
     this.qnAService      = qnAService ?? throw new ArgumentNullException(nameof(qnAService));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     this.telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
 }
예제 #12
0
 public BotController(IErrorService errorService,
                      IBotService botService,
                      ICardService cardService,
                      ISettingService settingService,
                      ICommonCardService commonCardService,
                      IQnAService qnaService) : base(errorService)
 {
     _botService        = botService;
     _settingService    = settingService;
     _cardService       = cardService;
     _commonCardService = commonCardService;
     _qnaService        = qnaService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="KnowledgeBaseResponse"/> class.
 /// </summary>
 /// <param name="qnaService">Question and answer maker service provider.</param>
 /// <param name="botOptions"> A set of key/value application bot configuration properties.</param>
 /// <param name="cardHelper">Instance of class that handles adaptive card helper methods.</param>
 /// <param name="localizer">Localization service.</param>
 /// <param name="logger">Logger implementation to send logs to the logger service.</param>
 public KnowledgeBaseResponse(
     IQnAService qnaService,
     IOptions <BotOptions> botOptions,
     CardHelper cardHelper,
     IStringLocalizer <Strings> localizer,
     ILogger <KnowledgeBaseResponse> logger)
 {
     this.qnaService = qnaService ?? throw new ArgumentNullException(nameof(qnaService));
     this.botOptions = botOptions ?? throw new ArgumentNullException(nameof(botOptions));
     this.cardHelper = cardHelper ?? throw new ArgumentNullException(nameof(cardHelper));
     this.localizer  = localizer ?? throw new ArgumentNullException(nameof(localizer));
     this.logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public OrchestratorService(
     IAnswersService answersService,
     ILuisService luisService,
     IQnAService qnaService,
     IDialogService dialogService,
     ConversationState conversationState
     )
 {
     _answersService    = answersService;
     _luisService       = luisService;
     _qnaService        = qnaService;
     _dialogService     = dialogService;
     _conversationState = conversationState;
 }
예제 #15
0
        public QnADialog(IQnAService qnaService, IConfiguration configuration)
            : base(nameof(QnADialog))
        {
            _qnaService    = qnaService;
            _configuration = configuration;

            // populate variables from config
            float.TryParse(_configuration["QnAHighConfidenceThreshold"], out highConfidenceThreshold);
            float.TryParse(_configuration["QnALowConfidenceThreshold"], out lowConfidenceThreshold);
            int.TryParse(_configuration["QnATopResults"], out maxQnaResults);
            noQnAResults                = _configuration["QnANoMatchFoundMessage"];
            learningCardTitle           = _configuration["QnALearningCard:Title"];
            learningCardNoMatchText     = _configuration["QnALearningCard:NoMatchText"];
            learningCardNoMatchResponse = _configuration["QnALearningCard:NoMatchResponse"];
        }
예제 #16
0
 public RootDialog(
     LogInDialog loginDialog,
     SelectSiteDialog selectSiteDialog,
     GetSiteDialog getSiteDialog,
     HelpDialog helpDialog,
     IAuthenticationService authenticationService,
     ILuisService luis,
     IQnAService qnaService) : base(luis)
 {
     _loginDialog           = loginDialog;
     _selectSiteDialog      = selectSiteDialog;
     _getSiteDialog         = getSiteDialog;
     _helpDialog            = helpDialog;
     _authenticationService = authenticationService;
     _qnaService            = qnaService;
 }
 public BotController(IErrorService errorService,
                      ICardService cardService,
                      IQnAService qnaService,
                      ISettingService settingService,
                      IGroupCardService groupCardService,
                      IModuleService moduleService,
                      IBotService botService,
                      IModuleSearchEngineService mdSearchEngineService
                      ) : base(errorService)
 {
     _cardService           = cardService;
     _qnaService            = qnaService;
     _settingService        = settingService;
     _groupCardService      = groupCardService;
     _moduleService         = moduleService;
     _mdSearchEngineService = mdSearchEngineService;
     _botService            = botService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QBotService"/> class.
 /// </summary>
 /// <param name="questionValidator">Question validator.</param>
 /// <param name="answerValidator">Answer validator.</param>
 /// <param name="questionRespository">Question repository.</param>
 /// <param name="teamsMessageService">Teams message service.</param>
 /// <param name="courseReader">Course reader.</param>
 /// <param name="qnAService">QnA Service.</param>
 /// <param name="userReaderService">User profile reader  service.</param>
 /// <param name="logger">Logger.</param>
 public QBotService(
     IQuestionValidator questionValidator,
     IAnswerValidator answerValidator,
     IQuestionRespository questionRespository,
     ITeamsMessageService teamsMessageService,
     ICourseReader courseReader,
     IQnAService qnAService,
     IUserReaderService userReaderService,
     ILogger <QBotService> logger)
 {
     this.questionValidator   = questionValidator ?? throw new ArgumentNullException(nameof(questionValidator));
     this.answerValidator     = answerValidator ?? throw new ArgumentNullException(nameof(answerValidator));
     this.questionRespository = questionRespository ?? throw new ArgumentNullException(nameof(questionRespository));
     this.teamsMessageService = teamsMessageService ?? throw new ArgumentNullException(nameof(teamsMessageService));
     this.courseReader        = courseReader ?? throw new ArgumentNullException(nameof(courseReader));
     this.qnAService          = qnAService ?? throw new ArgumentNullException(nameof(qnAService));
     this.userReaderService   = userReaderService ?? throw new ArgumentNullException(nameof(userReaderService));
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #19
0
        public QnABot(IConfiguration configuration,
                      ILogger <QnABot> logger,
                      IQnAService qnAService,
                      WelcomeCard welcomeDialog,
                      SupportTicketCard supportTicketCard,
                      BotConversationState botConversationState,
                      UserFeedbackCard userFeedbackCard,
                      Incident incident)
        {
            _configuration        = configuration;
            _logger               = logger;
            _qnAService           = qnAService;
            _welcomeDialog        = welcomeDialog;
            _supportTicketCard    = supportTicketCard;
            _botConversationState = botConversationState;
            _incident             = incident;
            _userFeedbackCard     = userFeedbackCard;

            int.TryParse(configuration["MinConfidenceScore"], out _minConfidenceScore);
        }
 /// <summary>
 /// Construct the QnA Scorable.
 /// </summary>
 public QnAMakerServiceScorable(IQnAService service, IBotToUser botToUser)
 {
     SetField.NotNull(out this.service, nameof(service), service);
     SetField.NotNull(out this.botToUser, nameof(botToUser), botToUser);
 }
예제 #21
0
 public QnADialog(IQnAService qnaService)
     : base(nameof(QnADialog))
 {
     _qnaService = qnaService;
 }
예제 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QnADialog"/> class.
 /// </summary>
 /// <param name="service">question and answer service</param>
 public QnADialog(IQnAService service) : base(service)
 {
 }
예제 #23
0
 public QnABot(ConversationState conversationState, UserState userState, IQnAService qnaService, ILogger <QnABot> logger)
     : base(conversationState, userState, new QnADialog(qnaService), logger)
 {
 }
 public FormQnAController(IErrorService errorService,
                          IQnAService qnaService
                          ) : base(errorService)
 {
     _qnaService = qnaService;
 }
예제 #25
0
 public Question(IQnAService service)
 {
     _answerService = service;
 }
예제 #26
0
 public QnAController(IOptions <AppSettings> appsettings,
                      IQnAService qnaservice)
 {
     this._appSettings = appsettings.Value;
     this.iQnAService  = qnaservice;
 }
 /// <summary>
 /// Construct the QnA Scorable.
 /// </summary>
 public QnAMakerScorable(IQnAService service, IBotToUser botToUser, ITraits <double> traits)
 {
     SetField.NotNull(out this.service, nameof(service), service);
     SetField.NotNull(out this.botToUser, nameof(botToUser), botToUser);
     SetField.NotNull(out this.traits, nameof(traits), traits);
 }
예제 #28
0
 public HomeController(IQnAService __IQnAService, IVideoGalleryService __IVideoGalleryService)
 {
     _IQnAService          = __IQnAService;
     _IVideoGalleryService = __IVideoGalleryService;
 }