feat: springboot starter支持月之暗面moonshot模型

This commit is contained in:
lidong 2024-06-25 11:31:30 +08:00
parent 806e46ee36
commit f17f4cea24
4 changed files with 79 additions and 0 deletions

View File

@ -77,6 +77,12 @@
<version>${agents-flex.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.agentsflex</groupId>
<artifactId>agents-flex-llm-moonshot</artifactId>
<version>${agents-flex.version}</version>
<optional>true</optional>
</dependency>
<!--llm end-->
<!--store start-->

View File

@ -0,0 +1,32 @@
package com.agentsflex.spring.boot.llm.moonshot;
import com.agentsflex.llm.moonshot.MoonshotLlm;
import com.agentsflex.llm.moonshot.MoonshotLlmConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
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;
/**
* Agents-Flex 月之暗面大语言模型自动配置
*
* @author lidong
* @since 2024-06-25
*/
@ConditionalOnClass(MoonshotLlm.class)
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(MoonshotProperties.class)
public class MoonshotAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public MoonshotLlm moonshotLlm(MoonshotProperties properties) {
MoonshotLlmConfig config = new MoonshotLlmConfig();
config.setApiKey(properties.getApiKey());
config.setEndpoint(properties.getEndpoint());
config.setModel(properties.getModel());
return new MoonshotLlm(config);
}
}

View File

@ -0,0 +1,40 @@
package com.agentsflex.spring.boot.llm.moonshot;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author lidong
* @since 2024-06-25
*/
@ConfigurationProperties(prefix = "agents-flex.llm.moonshot")
public class MoonshotProperties {
private String model = "moonshot-v1-8k";
private String endpoint = "https://api.moonshot.cn";
private String apiKey;
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
}

View File

@ -3,5 +3,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.agentsflex.spring.boot.llm.openai.OpenAiAutoConfiguration,\
com.agentsflex.spring.boot.llm.qwen.QwenAutoConfiguration,\
com.agentsflex.spring.boot.llm.spark.SparkAutoConfiguration,\
com.agentsflex.spring.boot.llm.moonshot.MoonshotAutoConfiguration,\
com.agentsflex.spring.boot.store.aliyun.AliyunAutoConfiguration,\
com.agentsflex.spring.boot.store.qcloud.QCloudStoreAutoConfiguration