Exemplo n.º 1
0
 /// <summary>
 /// Construct the LUIS model information.
 /// </summary>
 /// <param name="modelID">The LUIS model ID.</param>
 /// <param name="subscriptionKey">The LUIS subscription key.</param>
 /// <param name="apiVersion">The LUIS API version.</param>
 public LuisModelAttribute(string modelID, string subscriptionKey, LuisApiVersion apiVersion = LuisApiVersion.V2)
 {
     SetField.NotNull(out this.modelID, nameof(modelID), modelID);
     SetField.NotNull(out this.subscriptionKey, nameof(subscriptionKey), subscriptionKey);
     this.apiVersion = apiVersion;
     this.uriBase    = LuisEndpoints[this.apiVersion];
 }
Exemplo n.º 2
0
        public static Uri UriFor(LuisApiVersion apiVersion, string domain = null)
        {
            if (domain == null)
            {
                domain = apiVersion == LuisApiVersion.V2 ? "westus.api.cognitive.microsoft.com" : "api.projectoxford.ai/luis/v1/application";
            }

            return(new Uri(apiVersion == LuisApiVersion.V2 ? $"https://{domain}/luis/v2.0/apps/" : $"https://api.projectoxford.ai/luis/v1/application"));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Construct the LUIS model information.
 /// </summary>
 /// <param name="modelID">The LUIS model ID.</param>
 /// <param name="subscriptionKey">The LUIS subscription key.</param>
 /// <param name="apiVersion">The LUIS API version.</param>
 /// <param name="tKey">Azure Translator key if you want to support multiple language</param>
 /// <param name="dLang">Default language for your Intents for translation</param>
 public LuisModelAttribute(string modelID, string subscriptionKey, LuisApiVersion apiVersion = LuisApiVersion.V2, string tKey = "", string dLang = "en")
 {
     SetField.NotNull(out this.modelID, nameof(modelID), modelID);
     SetField.NotNull(out this.subscriptionKey, nameof(subscriptionKey), subscriptionKey);
     this.apiVersion      = apiVersion;
     this.translatorKey   = tKey;
     this.defaultLanguage = dLang;
     this.uriBase         = LuisEndpoints[this.apiVersion];
 }
Exemplo n.º 4
0
        /// <summary>
        /// Construct the LUIS model information.
        /// </summary>
        /// <param name="modelID">The LUIS model ID.</param>
        /// <param name="subscriptionKey">The LUIS subscription key.</param>
        /// <param name="apiVersion">The LUIS API version.</param>
        /// <param name="domain">Domain where LUIS model is located.</param>
        public LuisModelAttribute(string modelID, string subscriptionKey,
                                  LuisApiVersion apiVersion = LuisApiVersion.V2, string domain = null)
        {
            SetField.NotNull(out this.modelID, nameof(modelID), modelID);
            SetField.NotNull(out this.subscriptionKey, nameof(subscriptionKey), subscriptionKey);
            this.apiVersion = apiVersion;
            this.domain     = domain;
            this.uriBase    = UriFor(apiVersion, domain);

            this.Log = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LuisModelAttribute"/> class.
        /// </summary>
        /// <param name="modelID">The LUIS model ID.</param>
        /// <param name="subscriptionKey">The LUIS subscription key.</param>
        /// <param name="apiVersion">The LUIS API version.</param>
        /// <param name="domain">The URL domain for the model.</param>
        /// <param name="threshold">The threshold for the top scoring intent.</param>
        public LuisModelAttribute(
            string modelID,
            string subscriptionKey,
            LuisApiVersion apiVersion = LuisApiVersion.V2,
            string domain             = null,
            double threshold          = 0.0d)
        {
            SetField.NotNull(out this.modelID, nameof(modelID), modelID);
            SetField.NotNull(out this.subscriptionKey, nameof(subscriptionKey), subscriptionKey);
            this.ApiVersion = apiVersion;
            this.Domain     = domain;
            this.UriBase    = UriFor(apiVersion, domain);
            this.Threshold  = threshold;

            this.Log = true;
        }
Exemplo n.º 6
0
        public LuisModel(string modelId, string subscriptionKey, Uri uriBase, LuisApiVersion apiVersion = LuisApiVersion.V2)
        {
            if (string.IsNullOrEmpty(modelId))
            {
                throw new ArgumentNullException(nameof(modelId));
            }

            if (string.IsNullOrEmpty(subscriptionKey))
            {
                throw new ArgumentNullException(nameof(subscriptionKey));
            }

            ModelID         = modelId;
            SubscriptionKey = subscriptionKey;
            UriBase         = uriBase ?? throw new ArgumentNullException(nameof(uriBase));
            ApiVersion      = apiVersion;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Construct the LUIS model information.
 /// </summary>
 /// <param name="modelID">The LUIS model ID.</param>
 /// <param name="subscriptionKey">The LUIS subscription key.</param>
 /// <param name="apiVersion">The LUIS API version.</param>
 /// <param name="domain">Domain where LUIS model is located.</param>
 /// <param name="log">Allow LUIS to log query.</param>
 /// <param name="spellCheck">Control spell checking.</param>
 /// <param name="staging">Control whether or not to use staging endpoint.</param>
 /// <param name="verbose">Control verbose results.</param>
 public LuisModelAttribute(string modelID, string subscriptionKey,
                           LuisApiVersion apiVersion = LuisApiVersion.V2, string domain = null,
                           bool log = true, bool spellCheck = false, bool staging = false, bool verbose = false)
 {
     SetField.NotNull(out this.modelID, nameof(modelID), modelID);
     SetField.NotNull(out this.subscriptionKey, nameof(subscriptionKey), subscriptionKey);
     this.apiVersion = apiVersion;
     if (domain == null)
     {
         domain = apiVersion == LuisApiVersion.V2 ? "westus.api.cognitive.microsoft.com" : "api.projectoxford.ai/luis/v1/application";
     }
     this.log        = log;
     this.domain     = domain;
     this.spellCheck = spellCheck;
     this.staging    = staging;
     this.uriBase    = new Uri(apiVersion == LuisApiVersion.V2 ? $"https://{domain}/luis/v2.0/apps/" : $"https://api.projectoxford.ai/luis/v1/application");
     this.verbose    = verbose;
 }
 public CustomLuisAttribute(string modelID, string subscriptionKey, LuisApiVersion apiVersion = LuisApiVersion.V2, string domain = null, double threshold = 0)
     : base(modelID: ConfigurationManager.AppSettings["ModelId"], subscriptionKey: ConfigurationManager.AppSettings["LuisSubscriptionKey"])
 {
 }