Beispiel #1
0
 public LuisClient(LuisSettings settings, string fallbackMessage = "Sorry, I couldn't understand.")
 {
     AppId = settings.AppId;
     PredictionEndpoint        = settings.PredictionEndpoint;
     PredictionSubscriptionKey = settings.PredictionSubscriptionKey;
     SlotName        = settings.SlotName;
     VersionId       = settings.VersionId;
     FallbackMessage = fallbackMessage;
 }
        public static void ParsesAsLuisApp()
        {
            var settings = LuisSettings.FromJson(new JObject
            {
                { "name", "foo" },
            });

            settings.PrebuiltEntityTypes.Should().BeEmpty();
            settings.AppTemplate.Name.Should().Be("foo");
        }
Beispiel #3
0
 public VoiceController(ILogger <VoiceController> logger, ILUISRuntimeClient luisRuntimeClient,
                        IDictionary <string, CallState> callStates, VoiceConfig voiceConfig, LuisSettings luisSettings,
                        IHubContext <CallActivityHub> hubContext)
 {
     _logger            = logger;
     _luisRuntimeClient = luisRuntimeClient;
     _callStates        = callStates;
     _voiceConfig       = voiceConfig;
     _luisSettings      = luisSettings;
     _hubContext        = hubContext;
 }
        public static void ParsesPrebuiltEntities()
        {
            var settings = LuisSettings.FromJson(new JObject
            {
                { "prebuiltEntityTypes", new JObject {
                      { "foo", "bar" }
                  } },
            });

            settings.AppTemplate.Name.Should().BeNull();
            settings.PrebuiltEntityTypes.Should().Contain(new KeyValuePair <string, string>("foo", "bar"));
        }
        public LuisService(IOptions <LuisSettings> options,
                           ILUISAuthoringClient luisAuthoringClient,
                           ILUISRuntimeClient luisRuntimeClient,
                           IRedisCacheService redisCache,
                           HttpClient httpClient,
                           ILogger <LuisService> logger)
        {
            _redisCache   = redisCache;
            _luisSettings = options?.Value ?? throw new ArgumentNullException(nameof(options));
            _logger       = logger;
            _httpClient   = httpClient;

            _luisRuntimeClient   = luisRuntimeClient;
            _luisAuthoringClient = luisAuthoringClient;
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            var luisSettings = new LuisSettings();

            Configuration.GetSection("luisSettings").Bind(luisSettings);
            services.AddSingleton(luisSettings);

            services.AddSingleton <ILUISRuntimeClient>(
                new LUISRuntimeClient(
                    new ApiKeyServiceClientCredentials(luisSettings.ApiKey))
            {
                Endpoint = luisSettings.Endpoint
            });

            using (var fs = new FileStream("VoiceConfig.json", FileMode.Open))
            {
                using (var ss = new StreamReader(fs))
                {
                    var configStr = ss.ReadToEnd();
                    var config    = JsonConvert.DeserializeObject <Settings.VoiceConfig>(configStr);
                    services.AddSingleton(config);
                }
            }

            services.AddSingleton <IDictionary <string, CallState> >(new Dictionary <string, CallState>());

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSignalR();
        }
Beispiel #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureSession(services);

            services.AddMvc();
            ILuisSettings luisSettings = new LuisSettings(Configuration.GetSection("Luis"));

            services.AddSingleton(luisSettings);

            IBingSettings bingSettings = new BingSettings(Configuration.GetSection("Bing"));

            services.AddSingleton(bingSettings);

            IShareSettings shareSettings = new ShareSettings(Configuration.GetSection("Share"));

            services.AddSingleton(shareSettings);

            IKeyVaultSettings keyVaultSettings = new KeyVaultSettings(Configuration.GetSection("KeyVault"));

            services.AddSingleton(keyVaultSettings);

            IAdminSettings adminSettings = new AdminSettings(Configuration.GetSection("Admin"));

            services.AddSingleton(adminSettings);

            IOnboardingInfoSettings onboardingInfoSettings = new OnboardingInfoSettings(Configuration.GetSection("EmailService"), Configuration.GetSection("KeyVault"));

            services.AddSingleton(onboardingInfoSettings);
            IQnAMakerSettings qnAMakerSettings = new QnAMakerSettings(Configuration.GetSection("QnAMaker"));

            services.AddSingleton(qnAMakerSettings);

            services.AddSingleton <ILuisProxy, LuisProxy>();
            services.AddSingleton <ILuisBusinessLogic, LuisBusinessLogic>();
            services.AddSingleton <ITopicsResourcesBusinessLogic, TopicsResourcesBusinessLogic>();
            services.AddSingleton <IWebSearchBusinessLogic, WebSearchBusinessLogic>();
            services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>();
            services.AddSingleton <ICuratedExperienceBusinessLogic, CuratedExperienceBuisnessLogic>();
            services.AddTransient <IHttpClientService, HttpClientService>();
            services.AddSingleton <IUserProfileBusinessLogic, UserProfileBusinessLogic>();
            services.AddSingleton <IPersonalizedPlanBusinessLogic, PersonalizedPlanBusinessLogic>();
            services.AddSingleton <IStaticResourceBusinessLogic, StaticResourceBusinessLogic>();
            services.AddSingleton <IShareBusinessLogic, ShareBusinessLogic>();
            services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>();
            services.AddSingleton <IPersonalizedPlanEngine, PersonalizedPlanEngine>();
            services.AddSingleton <IA2JAuthorLogicParser, LogicParser>();
            services.AddSingleton <IA2JAuthorLogicInterpreter, LogicInterpreter>();
            services.AddSingleton <IPersonalizedPlanViewModelMapper, PersonalizedPlanViewModelMapper>();
            services.AddSingleton <IUserRoleBusinessLogic, UserRoleBusinessLogic>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <ISessionManager, SessionManager>();
            services.AddSingleton <IAdminBusinessLogic, AdminBusinessLogic>();
            services.AddSingleton <IStateProvinceBusinessLogic, StateProvinceBusinessLogic>();
            services.AddSingleton <IOnboardingInfoBusinessLogic, OnboardingInfoBusinessLogic>();
            services.AddSingleton <IQnABotBusinessLogic, QnABotBusinessLogic>();

            services.AddAuthentication(sharedOptions =>
            {
                sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            }).AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));

            services.AddAuthorization(options =>
            {
                options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
                                        .RequireAuthenticatedUser()
                                        .Build();
            });
            ConfigureCosmosDb(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Access2Justice API", Version = "1.0.0", Description = "List of all APIs for Access2Justice", TermsOfService = "None"
                });
                c.TagActionsBy(api => api.GroupName);
                c.DescribeAllEnumsAsStrings();
                c.OrderActionsBy((apiDesc) => $"{apiDesc.RelativePath}_{apiDesc.HttpMethod}");
                c.OperationFilter <FileUploadOperation>(); //Register File Upload Operation Filter
                c.OperationFilter <FileUploadOperationResource>();
                c.CustomSchemaIds(x => x.FullName);
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
        public static void ThrowsArgumentNull()
        {
            Action nullSettings = () => LuisSettings.FromJson(null);

            nullSettings.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("settings");
        }
 public LuisProgClient(IOptions <LuisSettings> options, HttpClient http) : base(options.Value.AuthoringKey, Location.WestUS, http)
 {
     _luisSettings = options.Value;
     _http         = http;
 }
Beispiel #10
0
 public PhraseService(IJsonConvertWrapper jsonConvert, IHttpClient httpClient, LuisSettings luisSettings)
 {
     _jsonConvert  = jsonConvert;
     _httpClient   = httpClient;
     _luisSettings = luisSettings;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LuisServiceProvider"/> class.
 /// </summary>
 /// <param name="configurationProvider">ConfigurationProvider fetch and store information in storage table.</param>
 /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
 public LuisServiceProvider(IConfigurationDataProvider configurationProvider, IOptionsMonitor <LuisSettings> optionsAccessor)
 {
     this.configurationProvider = configurationProvider;
     this.options = optionsAccessor.CurrentValue;
     this.InitializeLuisRecognizer();
 }
Beispiel #12
0
 public LuisAIEngine(LuisSettings settings)
 {
     Client      = new HttpClient();
     EndpointUri = settings.EndpointUri;
 }