public String CognizeDebug(String query)
        {
            var startlightResponse = IntentClassificatorSingleton.Instance.Cognize(query);

            logger.LogDebug($"[{LogPrefix.Processing}]: Starlight returned the following object for the query {query}: {startlightResponse}");

            var utterance  = new Utterance(startlightResponse);
            var highIntent = utterance.Intents.First(i => i.Score == utterance.Intents.Max(i => i.Score));

            logger.LogInformation($"[{LogPrefix.Analysis}]: The intent with the highest score for the query {query} was {highIntent.Name}, with a score of {highIntent.Score}");

            utterance.Response = Response.ResponseController.SetResponse(utterance);

            if (highIntent.Score <= .80)
            {
                logger.LogWarning($"[{LogPrefix.Processing}]: Polaris AI was not able to understand the query {query}. Highest intent score: {highIntent.Score}");
            }

            if (highIntent.Score <= .50)
            {
                logger.LogWarning($"[{LogPrefix.Analysis}]: The intent with the highest score for query {query} scored lower than 50%. Intent score {highIntent.Score}");
            }

            return(utterance.GetDebugLog());
        }
示例#2
0
        public static String CognizeDebug(String query)
        {
            Utterance utterance = new Utterance(
                IntentClassificatorSingleton.Instance.Cognize(query));

            utterance.Response = Response.ResponseController.SetResponse(utterance);

            return(utterance.GetDebugLog());
        }
示例#3
0
        public static String CognizeDebug(String query)
        {
            Log.Logger.Debug($"DEBUG: CognizeDebug called with query: {query}");
            Utterance utterance = new Utterance(
                IntentClassificatorSingleton.Instance.Cognize(query));

            utterance.Response = Response.ResponseController.SetResponse(utterance);

            return(utterance.GetDebugLog());
        }
示例#4
0
        public static JObject Cognize(String query)
        {
            Utterance utterance = new Utterance(
                IntentClassificatorSingleton.Instance.Cognize(query));

            utterance.Response = Response.ResponseController.SetResponse(utterance);

            _database.InsertRequestDetails(utterance);

            return(utterance.GetResponse());
        }
示例#5
0
        public static JObject Cognize(String query)
        {
            Log.Logger.Debug($"DEBUG: Cognize called with query: {query}");
            Utterance utterance = new Utterance(
                IntentClassificatorSingleton.Instance.Cognize(query));

            utterance.Response = Response.ResponseController.SetResponse(utterance);

            _database.InsertRequestDetails(utterance);

            return(utterance.GetResponse());
        }
示例#6
0
        public static String CognizeDebug(String query)
        {
            var start = DateTime.Now;

            Log.Information("query is {query}", query);
            Utterance utterance = new Utterance(
                IntentClassificatorSingleton.Instance.Cognize(query));

            Log.Information("the utternece is a questions? : {utterance}", utterance.IsQuestion.ToString());
            utterance.Response = Response.ResponseController.SetResponse(utterance);
            Log.Information("Utterence responce is {response}", utterance.Response);
            var end = DateTime.Now;

            Log.Information("Time to get a responce from starlight is {time}", (end - start));
            return(utterance.GetDebugLog());
        }
示例#7
0
        public void InsertRequestDetails(Utterance u)
        {
            var cultureInfo = new CultureInfo("en-US");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            try {
                using (SqlDataAdapter adapter = new SqlDataAdapter()) {
                    _connection.Open();

                    String sql =
                        $"INSERT INTO Request (query, [response-code], response) OUTPUT INSERTED.[request-id] " +
                        $"VALUES ('{u.Query.Replace("'", "''")}', {u.Code}, '{u.Response?.Replace("'", "''")}')";

                    adapter.InsertCommand = new SqlCommand(sql, _connection);
                    var id = adapter.InsertCommand.ExecuteScalar();

                    sql =
                        $"BEGIN " +
                        $"  INSERT INTO Entity ([request-id], [entity-content], [start-index], [end-index], date, time, type) " +
                        $"  VALUES ({id}, {GetJTokenStringFormatted(u.Entity["entity"])}, {GetJTokenNumberFormatted(u.Entity["startIndex"])}, {GetJTokenNumberFormatted(u.Entity["endIndex"])}, " +
                        $"  {GetJTokenStringFormatted(u.Entity["date"])}, {GetJTokenStringFormatted(u.Entity["time"])}, {GetJTokenStringFormatted(u.Entity["type"])}) " +
                        $"END " +
                        $"BEGIN " +
                        $"  IF NOT EXISTS (SELECT [intent-name] FROM Intent " +
                        $"                 WHERE [intent-name] = '{u.TopScoringIntent.Name}')" +
                        $"  BEGIN " +
                        $"      INSERT INTO Intent ([intent-name]) " +
                        $"      VALUES ('{u.TopScoringIntent.Name}') " +
                        $"  END " +
                        $"END ";

                    foreach (Intent intent in u.Intents)
                    {
                        sql = sql +
                              $"BEGIN " +
                              $"  IF NOT EXISTS (SELECT [intent-name] FROM Intent " +
                              $"                 WHERE [intent-name] = '{intent.Name}') " +
                              $"  BEGIN " +
                              $"      INSERT INTO Intent ([intent-name]) " +
                              $"      VALUES ('{intent.Name}') " +
                              $"  END " +
                              $"END " +
                              $"BEGIN " +
                              $"  INSERT INTO RequestIntent ([request-id], [intent-name], [is-top-scoring], [intent-score]) " +
                              $"  VALUES ({id}, '{intent.Name}', {(intent == u.TopScoringIntent ? 1 : 0)}, {intent.Score}) " +
                              $"END ";
                    }

                    adapter.InsertCommand = new SqlCommand(sql, _connection);
                    adapter.InsertCommand.ExecuteNonQuery();
                }
            }
            catch (System.Data.SqlClient.SqlException ex) {
                Console.WriteLine(ex);
            }
            finally {
                _connection.Close();
            }
        }