using Microsoft.Extensions.Configuration;
using RestSharp;

namespace LazyBear.MCP.Services.Qdrant;

public sealed class QdrantClientProvider
{
    public RestClient? Client { get; }

    public string? InitializationError { get; }

    public QdrantClientProvider(IConfiguration configuration)
    {
        try
        {
            var url = configuration["Qdrant:Url"];
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new InvalidOperationException("Qdrant:Url не настроен в конфигурации.");
            }

            Client = new RestClient(url);
        }
        catch (Exception ex)
        {
            InitializationError = $"{ex.GetType().Name}: {ex.Message}";
        }
    }
}
