All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ape9527.core.runner.InitChatGPTService Maven / Gradle / Ivy

The newest version!
package com.ape9527.core.runner;

import com.ape9527.core.annotation.CustomizedValue;
import com.ape9527.utils.openai.OpenAiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 初始化ChatGPT服务配置
 *
 * @author YuanShuai[[email protected]]
 */
@Component
@Slf4j
public class InitChatGPTService implements ApplicationRunner {

    /**
     * 请求代理
     */
    @CustomizedValue("${ape.openai.vpn}")
    private String vpn;

    /**
     * API_KEY
     */
    @CustomizedValue("${ape.openai.apikey}")
    private String apiKey;

    /**
     * model
     */
    @CustomizedValue("${ape.openai.model}")
    private String model;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("Initialize the configuration of the chat GPT service...");
        OpenAiUtil.BASE_URL = vpn;
        OpenAiUtil.API_KEY = apiKey;
        OpenAiUtil.MODEL = model;
        log.info("The chat GPT service configuration was initialized successfully!");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy