Ejemplo n.º 1
0
        /// <summary>
        /// 查询LUIS意图对应的回答
        /// </summary>
        /// <param name="query">请求的文本</param>
        /// <returns></returns>
        public static string PostMessage(string query)
        {
            LuisMessage luisMsg = LuisAPI.Default.GetLuis(query);

            if (luisMsg == null || luisMsg.entities == null || luisMsg.entities.Count <= 0)
            {
                return("好尴尬啊,小哈有点被你整懵逼了");
            }
            string reponse = luisMsg.topScoringIntent.intent;

            return(reponse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 请求LUIS
        /// </summary>
        /// <param name="Query">请求内容</param>
        /// <returns>LUIS返回的对象</returns>
        public LuisMessage GetLuis(string Query)
        {
            Query = Uri.EscapeDataString(Query);
            LuisMessage Data = new LuisMessage();

            using (HttpClient client = new HttpClient())
            {
                string RequestURI       = string.Format(URI, Query);
                var    task             = client.GetAsync(RequestURI);
                HttpResponseMessage msg = task.Result;
                if (msg.IsSuccessStatusCode)
                {
                    var task1            = msg.Content.ReadAsStringAsync();
                    var JsonDataResponse = task1.Result;
                    Data = JsonConvert.DeserializeObject <LuisMessage>(JsonDataResponse);
                }
            }
            return(Data);
        }