コード例 #1
0
        public ActionResult <RasaVersionModel> Get()
        {
            var status = new RasaStatusModel();

            status.AvailableProjects = JObject.FromObject(new RasaProjectModel
            {
                Status          = "ready",
                AvailableModels = new List <string> {
                    "<model_XXXXXX>"
                }
            });

            return(Ok(status));
        }
コード例 #2
0
ファイル: StatusController.cs プロジェクト: wkke/BotSharp
        public ActionResult <RasaVersionModel> Get()
        {
            var status = new RasaStatusModel();

            status.AvailableProjects    = JObject.FromObject(new { });
            status.MaxTrainingProcesses = 1;

            // scan dir, get all models
            var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects");

            if (!Directory.Exists(projectPath))
            {
                Directory.CreateDirectory(projectPath);
            }

            var projectDirs = Directory.GetDirectories(projectPath);

            for (int idx = 0; idx < projectDirs.Length; idx++)
            {
                string project   = projectDirs[idx].Split('\\').Last();
                var    modelDirs = Directory.GetDirectories(projectDirs[idx]);

                List <string> availableModels = new List <string>();

                for (int mIdx = 0; mIdx < modelDirs.Length; mIdx++)
                {
                    string model = modelDirs[mIdx].Split('\\').Last();
                    if (model.StartsWith(project + "_"))
                    {
                        availableModels.Add(model);
                    }
                }

                status.AvailableProjects.Add(project, JObject.FromObject(new RasaProjectModel
                {
                    Status          = "ready",
                    AvailableModels = availableModels
                }));
            }

            return(Ok(status));
        }