初始化
This commit is contained in:
56
easy-agents-spring-boot-starter/pom.xml
Normal file
56
easy-agents-spring-boot-starter/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.easyagents</groupId>
|
||||
<artifactId>easy-agents-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<name>easy-agents-spring-boot-starter</name>
|
||||
<artifactId>easy-agents-spring-boot-starter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.easyagents</groupId>
|
||||
<artifactId>easy-agents-bom</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.easyagents.spring.boot.llm.deepseek;
|
||||
|
||||
import com.easyagents.llm.deepseek.DeepseekConfig;
|
||||
import com.easyagents.llm.deepseek.DeepseekChatModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Easy-Agents 大语言模型自动配置。
|
||||
* DeepSeek
|
||||
*/
|
||||
@ConditionalOnClass(DeepseekChatModel.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(DeepSeekProperties.class)
|
||||
public class DeepSeekAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public DeepseekChatModel deepseekLlm(DeepSeekProperties properties) {
|
||||
DeepseekConfig config = new DeepseekConfig();
|
||||
config.setModel(properties.getModel());
|
||||
config.setEndpoint(properties.getEndpoint());
|
||||
config.setApiKey(properties.getApiKey());
|
||||
return new DeepseekChatModel(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.easyagents.spring.boot.llm.deepseek;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "easy-agents.llm.deepseek")
|
||||
public class DeepSeekProperties {
|
||||
|
||||
private String model = "deepseek-chat";
|
||||
private String endpoint = "https://api.deepseek.com";
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.easyagents.spring.boot.llm.ollama;
|
||||
|
||||
import com.easyagents.llm.ollama.OllamaChatModel;
|
||||
import com.easyagents.llm.ollama.OllamaChatConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Easy-Agents Ollama自动配置。
|
||||
*
|
||||
* @author hustlelr
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@ConditionalOnClass(OllamaChatModel.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(OllamaProperties.class)
|
||||
public class OllamaAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OllamaChatModel ollamaLlm(OllamaProperties properties) {
|
||||
OllamaChatConfig config = new OllamaChatConfig();
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setEndpoint(properties.getEndpoint());
|
||||
config.setModel(properties.getModel());
|
||||
config.setThinkingEnabled(properties.getThink());
|
||||
return new OllamaChatModel(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.easyagents.spring.boot.llm.ollama;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author hustlelr
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.llm.ollama")
|
||||
public class OllamaProperties {
|
||||
|
||||
private String model;
|
||||
private String endpoint = "http://localhost:11434";
|
||||
private String apiKey;
|
||||
private Boolean think;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Boolean getThink() {
|
||||
return think;
|
||||
}
|
||||
|
||||
public void setThink(Boolean think) {
|
||||
this.think = think;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.easyagents.spring.boot.llm.openai;
|
||||
|
||||
import com.easyagents.llm.openai.OpenAIChatModel;
|
||||
import com.easyagents.llm.openai.OpenAIChatConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Easy-Agents 大语言模型自动配置。
|
||||
*
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConditionalOnClass(OpenAIChatModel.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(OpenAIProperties.class)
|
||||
public class OpenAIAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OpenAIChatModel openAILlm(OpenAIProperties properties) {
|
||||
OpenAIChatConfig config = new OpenAIChatConfig();
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setEndpoint(properties.getEndpoint());
|
||||
config.setModel(properties.getModel());
|
||||
config.setRequestPath(properties.getRequestPath());
|
||||
return new OpenAIChatModel(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.easyagents.spring.boot.llm.openai;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.llm.openai")
|
||||
public class OpenAIProperties {
|
||||
|
||||
private String model = "gpt-3.5-turbo";
|
||||
private String endpoint = "https://api.openai.com";
|
||||
private String apiKey;
|
||||
private String requestPath = "/v1/chat/completions";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String getRequestPath() {
|
||||
return requestPath;
|
||||
}
|
||||
|
||||
public void setRequestPath(String requestPath) {
|
||||
this.requestPath = requestPath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.easyagents.spring.boot.llm.qwen;
|
||||
|
||||
import com.easyagents.llm.qwen.QwenChatModel;
|
||||
import com.easyagents.llm.qwen.QwenChatConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Easy-Agents 大语言模型自动配置。
|
||||
*
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConditionalOnClass(QwenChatModel.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(QwenProperties.class)
|
||||
public class QwenAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public QwenChatModel qwenLlm(QwenProperties properties) {
|
||||
QwenChatConfig config = new QwenChatConfig();
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setEndpoint(properties.getEndpoint());
|
||||
config.setModel(properties.getModel());
|
||||
return new QwenChatModel(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.easyagents.spring.boot.llm.qwen;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.llm.qwen")
|
||||
public class QwenProperties {
|
||||
|
||||
private String model = "qwen-turbo";
|
||||
private String endpoint = "https://dashscope.aliyuncs.com";
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.easyagents.spring.boot.store.aliyun;
|
||||
|
||||
import com.easyagents.store.aliyun.AliyunVectorStore;
|
||||
import com.easyagents.store.aliyun.AliyunVectorStoreConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(AliyunVectorStore.class)
|
||||
@EnableConfigurationProperties(AliyunProperties.class)
|
||||
public class AliyunAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public AliyunVectorStore aliyunVectorStore(AliyunProperties properties) {
|
||||
AliyunVectorStoreConfig config = new AliyunVectorStoreConfig();
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setEndpoint(properties.getEndpoint());
|
||||
config.setDatabase(properties.getDatabase());
|
||||
config.setDefaultCollectionName(properties.getDefaultCollectionName());
|
||||
return new AliyunVectorStore(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.easyagents.spring.boot.store.aliyun;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.store.aliyun")
|
||||
public class AliyunProperties {
|
||||
|
||||
private String endpoint;
|
||||
private String apiKey;
|
||||
private String database;
|
||||
private String defaultCollectionName;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public String getDefaultCollectionName() {
|
||||
return defaultCollectionName;
|
||||
}
|
||||
|
||||
public void setDefaultCollectionName(String defaultCollectionName) {
|
||||
this.defaultCollectionName = defaultCollectionName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.chroma;
|
||||
|
||||
import com.easyagents.store.chroma.ChromaVectorStore;
|
||||
import com.easyagents.store.chroma.ChromaVectorStoreConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Chroma自动配置类
|
||||
*
|
||||
* @author easy-agents
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ChromaVectorStore.class)
|
||||
@EnableConfigurationProperties(ChromaProperties.class)
|
||||
public class ChromaAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ChromaVectorStore chromaVectorStore(ChromaProperties properties) {
|
||||
ChromaVectorStoreConfig config = new ChromaVectorStoreConfig();
|
||||
config.setHost(properties.getHost());
|
||||
config.setPort(properties.getPort());
|
||||
config.setCollectionName(properties.getCollectionName());
|
||||
config.setAutoCreateCollection(properties.isAutoCreateCollection());
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setTenant(properties.getTenant());
|
||||
config.setDatabase(properties.getDatabase());
|
||||
|
||||
return new ChromaVectorStore(config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.chroma;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Chroma配置属性类
|
||||
*
|
||||
* @author easy-agents
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.store.chroma")
|
||||
public class ChromaProperties {
|
||||
|
||||
private String host = "localhost";
|
||||
|
||||
private int port = 8000;
|
||||
|
||||
private String collectionName = "default_collection";
|
||||
|
||||
private boolean autoCreateCollection = true;
|
||||
|
||||
private String apiKey;
|
||||
|
||||
private String tenant = "default_tenant";
|
||||
|
||||
private String database = "default_database";
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getCollectionName() {
|
||||
return collectionName;
|
||||
}
|
||||
|
||||
public void setCollectionName(String collectionName) {
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
|
||||
public boolean isAutoCreateCollection() {
|
||||
return autoCreateCollection;
|
||||
}
|
||||
|
||||
public void setAutoCreateCollection(boolean autoCreateCollection) {
|
||||
this.autoCreateCollection = autoCreateCollection;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public void setTenant(String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.elasticsearch;
|
||||
|
||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import com.easyagents.store.elasticsearch.ElasticSearchVectorStore;
|
||||
import com.easyagents.store.elasticsearch.ElasticSearchVectorStoreConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2024/8/13 上午11:26
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ElasticSearchVectorStore.class)
|
||||
@EnableConfigurationProperties(ElasticSearchProperties.class)
|
||||
public class ElasticSearchAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ElasticSearchVectorStore elasticSearchVectorStore(ElasticSearchProperties properties,
|
||||
@Autowired(required = false) ElasticsearchClient client) {
|
||||
ElasticSearchVectorStoreConfig config = new ElasticSearchVectorStoreConfig();
|
||||
config.setServerUrl(properties.getServerUrl());
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setUsername(properties.getUsername());
|
||||
config.setPassword(properties.getPassword());
|
||||
config.setDefaultIndexName(properties.getDefaultIndexName());
|
||||
if (client != null) {
|
||||
return new ElasticSearchVectorStore(config, client);
|
||||
}
|
||||
return new ElasticSearchVectorStore(config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.elasticsearch;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2024/8/13 上午11:25
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.store.elasticsearch")
|
||||
public class ElasticSearchProperties {
|
||||
|
||||
private String serverUrl = "https://localhost:9200";
|
||||
|
||||
private String apiKey;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String defaultIndexName = "easy-agents-default";
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getDefaultIndexName() {
|
||||
return defaultIndexName;
|
||||
}
|
||||
|
||||
public void setDefaultIndexName(String defaultIndexName) {
|
||||
this.defaultIndexName = defaultIndexName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.opensearch;
|
||||
|
||||
import com.easyagents.store.opensearch.OpenSearchVectorStore;
|
||||
import com.easyagents.store.opensearch.OpenSearchVectorStoreConfig;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2024/8/13 上午11:26
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(OpenSearchVectorStore.class)
|
||||
@EnableConfigurationProperties(OpenSearchProperties.class)
|
||||
public class OpenSearchAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OpenSearchVectorStore openSearchVectorStore(OpenSearchProperties properties,
|
||||
@Autowired(required = false) OpenSearchClient client) {
|
||||
OpenSearchVectorStoreConfig config = new OpenSearchVectorStoreConfig();
|
||||
config.setServerUrl(properties.getServerUrl());
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setUsername(properties.getUsername());
|
||||
config.setPassword(properties.getPassword());
|
||||
config.setDefaultIndexName(properties.getDefaultIndexName());
|
||||
if (client != null) {
|
||||
return new OpenSearchVectorStore(config, client);
|
||||
}
|
||||
return new OpenSearchVectorStore(config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.easyagents.spring.boot.store.opensearch;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2024/8/13 上午11:25
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.store.opensearch")
|
||||
public class OpenSearchProperties {
|
||||
|
||||
private String serverUrl = "https://localhost:9200";
|
||||
|
||||
private String apiKey;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String defaultIndexName = "easy-agents-default";
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getDefaultIndexName() {
|
||||
return defaultIndexName;
|
||||
}
|
||||
|
||||
public void setDefaultIndexName(String defaultIndexName) {
|
||||
this.defaultIndexName = defaultIndexName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.easyagents.spring.boot.store.qcloud;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "easy-agents.store.qcloud")
|
||||
public class QCloudProperties {
|
||||
|
||||
private String host;
|
||||
private String apiKey;
|
||||
private String account;
|
||||
private String database;
|
||||
private String defaultCollectionName;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public String getDefaultCollectionName() {
|
||||
return defaultCollectionName;
|
||||
}
|
||||
|
||||
public void setDefaultCollectionName(String defaultCollectionName) {
|
||||
this.defaultCollectionName = defaultCollectionName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.easyagents.spring.boot.store.qcloud;
|
||||
|
||||
import com.easyagents.store.qcloud.QCloudVectorStore;
|
||||
import com.easyagents.store.qcloud.QCloudVectorStoreConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2024-04-10
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(QCloudVectorStore.class)
|
||||
@EnableConfigurationProperties(QCloudProperties.class)
|
||||
public class QCloudStoreAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public QCloudVectorStore qCloudVectorStore(QCloudProperties properties) {
|
||||
QCloudVectorStoreConfig config = new QCloudVectorStoreConfig();
|
||||
config.setHost(properties.getHost());
|
||||
config.setApiKey(properties.getApiKey());
|
||||
config.setAccount(properties.getAccount());
|
||||
config.setDatabase(properties.getDatabase());
|
||||
config.setDefaultCollectionName(properties.getDefaultCollectionName());
|
||||
return new QCloudVectorStore(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.easyagents.spring.boot.chatModel.chatglm.ChatglmAutoConfiguration,\
|
||||
com.easyagents.spring.boot.chatModel.openai.OpenAIAutoConfiguration,\
|
||||
com.easyagents.spring.boot.chatModel.qwen.QwenAutoConfiguration,\
|
||||
com.easyagents.spring.boot.chatModel.spark.SparkAutoConfiguration,\
|
||||
com.easyagents.spring.boot.store.aliyun.AliyunAutoConfiguration,\
|
||||
com.easyagents.spring.boot.store.qcloud.QCloudStoreAutoConfiguration,\
|
||||
com.easyagents.spring.boot.chatModel.ollama.OllamaAutoConfiguration,\
|
||||
com.easyagents.spring.boot.chatModel.deepseek.DeepSeekAutoConfiguration,\
|
||||
com.easyagents.spring.boot.store.chroma.ChromaAutoConfiguration
|
||||
@@ -0,0 +1,8 @@
|
||||
com.easyagents.spring.boot.chatModel.chatglm.ChatglmAutoConfiguration
|
||||
com.easyagents.spring.boot.chatModel.openai.OpenAIAutoConfiguration
|
||||
com.easyagents.spring.boot.chatModel.qwen.QwenAutoConfiguration
|
||||
com.easyagents.spring.boot.chatModel.spark.SparkAutoConfiguration
|
||||
com.easyagents.spring.boot.store.aliyun.AliyunAutoConfiguration
|
||||
com.easyagents.spring.boot.store.qcloud.QCloudStoreAutoConfiguration
|
||||
com.easyagents.spring.boot.chatModel.ollama.OllamaAutoConfiguration
|
||||
com.easyagents.spring.boot.store.chroma.ChromaAutoConfiguration
|
||||
Reference in New Issue
Block a user