Beispiel #1
0
        public static Intent GetIntent(this IBotPlatform bot, Database dc, string intentId)
        {
            var intent = dc.Table <Intent>()
                         .Include(x => x.Contexts)
                         .Include(x => x.Responses).ThenInclude(x => x.Contexts)
                         .Include(x => x.Responses).ThenInclude(x => x.Parameters).ThenInclude(x => x.Prompts)
                         .Include(x => x.Responses).ThenInclude(x => x.Messages)
                         .Include(x => x.UserSays).ThenInclude(x => x.Data)
                         .FirstOrDefault(x => x.Id == intentId);

            // order parts by time
            intent.UserSays.ForEach(x => x.Data = x.Data.OrderBy(d => d.UpdatedTime).ToList());

            return(intent);
        }
Beispiel #2
0
        private Agent LoadAgent()
        {
            _platform = new BotSharpAi();

            // Load agent
            var    projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", "Spotify");
            string model       = Directory.GetDirectories(projectPath).Where(x => x.Contains("model_")).Last().Split(Path.DirectorySeparatorChar).Last();
            var    modelPath   = Path.Combine(projectPath, model);
            var    agent       = _platform.LoadAgentFromFile(modelPath);

            // Init samples
            Samples = new List <Tuple <AIRequest, string> >();

            /*agent.Corpus.UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>
             * {
             *  new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music.play", Text = "play the 50 Great Beatles Songs playlist in Prime Music"},
             *  new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music.play", Text = "reproduce a the track Monster by Rihanna ft Eminem"},
             *  new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music_player_control.add_favorite", Text = "add this song to my favourites"}
             * };*/
            agent.Corpus.UserSays.ForEach(intent =>
            {
                Samples.Add(new Tuple <AIRequest, string>(new AIRequest
                {
                    AgentDir = projectPath,
                    Model    = model,
                    Query    = new String[]
                    {
                        intent.Text
                    }
                }, intent.Intent));
            });

            //Samples.Shuffle();

            var samples = String.Join("\r\n", Samples.Select(x => $"__label__{x.Item2} {x.Item1.Query[0]}").ToList());

            return(agent);
        }
Beispiel #3
0
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public AgentController(IBotPlatform platform)
 {
     _platform = platform;
 }
Beispiel #4
0
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public DialogController(IBotPlatform platform)
 {
     _platform = platform;
 }
Beispiel #5
0
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public EntityController(IBotPlatform platform)
 {
     _platform = platform;
 }
Beispiel #6
0
 /// <summary>
 /// Initialize status controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public StatusController(IBotPlatform platform)
 {
     _platform = platform;
 }
Beispiel #7
0
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public TrainController(IBotPlatform platform)
 {
     _platform = platform;
 }
Beispiel #8
0
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public QueryController(IBotPlatform platform)
 {
     _platform = platform;
 }
 /// <summary>
 /// Initialize dialog controller and get a platform instance
 /// </summary>
 /// <param name="platform"></param>
 public ParseController(IBotPlatform platform)
 {
     _platform = platform;
 }