<?php

namespace KupShop\LLMBundle\Util;

use KupShop\KupShopBundle\Config;
use KupShop\LLMBundle\LlmProviders\AbstractLlmProvider;
use KupShop\LLMBundle\LlmProviders\DummyDataLlmProvider;
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
use Symfony\Component\DependencyInjection\ServiceLocator;

class LlmProviderUtil
{
    public function __construct(
        /** @param ServiceLocator<AbstractLlmProvider> $serviceLocator */
        #[TaggedLocator(tag: 'kupshop.llm.provider', defaultIndexMethod: 'getLabel')] private ServiceLocator $serviceLocator,
    ) {
    }

    public function getAdminModalProvider(): AbstractLlmProvider
    {
        $providerLabel = Config::get()['Modules']['llm']['provider'] ?? DummyDataLlmProvider::LABEL;

        return $this->serviceLocator->get($providerLabel);
    }
}
