package com.seer.teach.ai.client.model;

import io.micrometer.observation.ObservationRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.model.tool.DefaultToolExecutionEligibilityPredicate;
import org.springframework.ai.model.tool.ToolCallingManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestClient;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * 平台模型管理器抽象基类
 * 提供通用的模型管理功能实现，减少代码重复
 *
 * @author Captain
 * @since 2025-12-26
 */
@Slf4j
public abstract class AbstractAiModelClient implements AiModelClient {
    
    @Autowired(required = false)
    protected ResponseErrorHandler responseErrorHandler;

    @Autowired(required = false)
    @Qualifier("aiRestClient")
    protected RestClient.Builder restClientBuilder;

    @Autowired(required = false)
    @Qualifier("aiWebClient")
    protected WebClient.Builder webClientBuilder;

    @Autowired
    protected RetryTemplate retryTemplate;

    @Autowired
    protected ToolCallingManager toolCallingManager;

    protected ObservationRegistry observationRegistry = ObservationRegistry.create();

    protected final DefaultToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate = new DefaultToolExecutionEligibilityPredicate();

}