package com.seer.teach.ai.client;

import cn.hutool.core.collection.CollectionUtil;
import com.seer.teach.ai.client.model.AiModelClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 平台模型管理器接口
 * 定义了平台特定的模型管理功能
 *
 * @since 2025-12-25
 */
@Slf4j
@Service
public class AiModelClientFactoryImpl implements AiModelClientFactory {

    private final Map<String, AiModelClient> serviceMap = new ConcurrentHashMap<>();


    public AiModelClientFactoryImpl(List<AiModelClient> platformServices){
        if(CollectionUtil.isEmpty(platformServices)){
            return;
        }
        for (AiModelClient platform : platformServices) {
            register(platform);
        }
    }

    public void register(AiModelClient platformManager) {
        String platformName = platformManager.getPlatformName();
        serviceMap.put(platformName, platformManager);
    }

    @Override
    public AiModelClient getClient(String platform) {
        return serviceMap.get(platform);
    }
}