using Services;
using Services.ReActAgent;

namespace ReAct_PME.ViewModels
{
    public class ParametresTF_From_DSF_VM
    {
        private readonly IToastNotifier _Notifier;
        public string InputPath { get; set; } = "";
        public string OutputPath { get; set; } = "";
        public bool IsApiExterne { get; set; } = false;


        public ParametresTF_From_DSF_VM(IToastNotifier notifier)
        {
            _Notifier = notifier;
            (string inputPath, string outputPath) = TF_From_DSFService.LoadParametres();
            InputPath = inputPath;
            OutputPath = outputPath;
        }

        public bool SaveData()
        {
            return TF_From_DSFService.SaveParametres(InputPath, OutputPath);
        }

        public async Task<(bool, string)> Traitement()
        {
            if (!IsApiExterne)
            {
                var b = await ReActAgent.IsOllamaActif(true);
                if (!b)
                {
                    _Notifier.ShowToast("Ollama n'est pas démarré. Veuillez lancer Ollama Desktop ou le service Ollama.");
                    return (false, "");

                }
            }
            return await TF_From_DSFService.Traitement(InputPath, OutputPath, IsApiExterne);
        }
    }
}
