package com.xunhong.erp.turbo.ai.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.ai.deepseek.api.DeepSeekApi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
@EnableConfigurationProperties(DeepSeekProperties.class)
@RequiredArgsConstructor
public class DeepSeekAutoConfiguration {

	private final DeepSeekProperties properties;

	@Bean
	@ConditionalOnMissingBean
	public DeepSeekChatModel deepSeekChatModel() {
		System.out.println(">>>>>>>>>>> deepseek config init.");
		DeepSeekApi deepSeekApi = DeepSeekApi.builder().apiKey(properties.getApiKey()).build();
		return DeepSeekChatModel.builder().deepSeekApi(deepSeekApi).build();
	}

}
