Esempio n. 1
0
        protected async Task <LuisResponse> MakeCall2(string text, ILuisConfiguration configuration)
        {
            var client      = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", configuration.ApiKey);

            queryString["q"] = text;


            queryString["timezoneOffset"] = "0";
            queryString["verbose"]        = "true";
            queryString["spellCheck"]     = "false";
            queryString["staging"]        = "false";

            var uri = "https://" + configuration.Domain + ".api.cognitive.microsoft.com/luis/v2.0/apps/" + configuration.ApiId + "?" + queryString;

            var response = await client.GetAsync(uri);

            var strResponseContent = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <LuisResponse>(strResponseContent);

            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LuisNLUTrainClient"/> class.
 /// </summary>
 /// <param name="luisConfiguration">LUIS configuration.</param>
 /// <param name="luisSettings">LUIS settings.</param>
 /// <param name="luisClient">LUIS client.</param>
 public LuisNLUTrainClient(ILuisConfiguration luisConfiguration, LuisSettings luisSettings, ILuisTrainClient luisClient)
 {
     this.LuisConfiguration = luisConfiguration ?? throw new ArgumentNullException(nameof(luisConfiguration));
     this.LuisSettings      = luisSettings ?? throw new ArgumentNullException(nameof(luisSettings));
     this.LuisClient        = luisClient ?? throw new ArgumentNullException(nameof(luisClient));
     this.LuisAppId         = luisConfiguration.AppId;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LuisNLUTrainClient"/> class.
 /// </summary>
 /// <param name="luisConfiguration">LUIS configuration.</param>
 /// <param name="luisTemplate">LUIS app template.</param>
 /// <param name="luisClient">LUIS client.</param>
 public LuisNLUTrainClient(ILuisConfiguration luisConfiguration, LuisApp luisTemplate, ILuisTrainClient luisClient)
 {
     this.LuisConfiguration = luisConfiguration ?? throw new ArgumentNullException(nameof(luisConfiguration));
     this.LuisTemplate      = luisTemplate ?? throw new ArgumentNullException(nameof(luisTemplate));
     this.LuisClient        = luisClient ?? throw new ArgumentNullException(nameof(luisClient));
     this.LuisAppId         = luisConfiguration.AppId;
     this.LuisAppCreated    = luisConfiguration.AppCreated;
 }
Esempio n. 4
0
        public LuisTestClient(ILuisConfiguration luisConfiguration)
        {
            this.LuisConfiguration = luisConfiguration ?? throw new ArgumentNullException(nameof(luisConfiguration));
            var endpointCredentials = new ApiKeyServiceClientCredentials(luisConfiguration.EndpointKey);

            this.RuntimeClient = new LUISRuntimeClient(endpointCredentials)
            {
                Endpoint = $"{Protocol}{luisConfiguration.EndpointRegion}{Domain}",
            };
        }
Esempio n. 5
0
        public LuisTrainClient(ILuisConfiguration luisConfiguration)
        {
            this.LuisConfiguration = luisConfiguration ?? throw new ArgumentNullException(nameof(luisConfiguration));
            var authoringCredentials = new ApiKeyServiceClientCredentials(luisConfiguration.AuthoringKey);

            this.AuthoringClient = new LUISAuthoringClient(authoringCredentials)
            {
                Endpoint = $"{Protocol}{luisConfiguration.AuthoringRegion}{Domain}",
            };
        }
Esempio n. 6
0
        public LuisTestClient(ILuisConfiguration luisConfiguration)
        {
            this.LuisConfiguration = luisConfiguration ?? throw new ArgumentNullException(nameof(luisConfiguration));
            var endpointCredentials = new ApiKeyServiceClientCredentials(luisConfiguration.PredictionKey);

            this.RuntimeClient = new LUISRuntimeClient(endpointCredentials)
            {
                Endpoint = luisConfiguration.PredictionEndpoint,
            };
        }
Esempio n. 7
0
        public static AzureSubscriptionInfo Create(ILuisConfiguration luisConfiguration)
        {
            if (luisConfiguration.AzureSubscriptionId == null ||
                luisConfiguration.AzureResourceGroup == null ||
                luisConfiguration.PredictionResourceName == null ||
                luisConfiguration.ArmToken == null)
            {
                return(null);
            }

            return(new AzureSubscriptionInfo(
                       luisConfiguration.AzureSubscriptionId,
                       luisConfiguration.AzureResourceGroup,
                       luisConfiguration.PredictionResourceName));
        }