通过yml开关控制使用哪些模型和向量库

This commit is contained in:
thinkgem
2025-06-18 10:59:44 +08:00
parent 28293383dd
commit 5fc096ab0a
4 changed files with 46 additions and 9 deletions

View File

@@ -43,11 +43,11 @@
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
<!-- 本地大模型
<!-- 本地大模型 -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-ollama</artifactId>
</dependency> -->
</dependency>
<!-- 向量数据库 -->
<dependency>
@@ -65,19 +65,19 @@
<artifactId>httpclient5</artifactId>
</dependency>
<!-- PG 向量数据库
<!-- PG 向量数据库 -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-pgvector</artifactId>
</dependency> -->
</dependency>
<!-- ES 向量数据库
<!-- ES 向量数据库 -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-elasticsearch</artifactId>
</dependency> -->
</dependency>
<!-- Milvus 向量数据库
<!-- Milvus 向量数据库 -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-milvus</artifactId>
@@ -92,7 +92,7 @@
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-aarch_64</classifier>
</dependency> -->
</dependency>
<!-- HTML 转 Markdown -->
<dependency>

View File

@@ -1,6 +1,7 @@
package com.jeesite.modules.cms.ai.properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
@ConfigurationProperties("spring.ai")
public class CmsAiProperties {
@@ -20,6 +21,12 @@ public class CmsAiProperties {
*/
private String defaultPromptTemplate = "";
/**
* 向量数据库设置
*/
@NestedConfigurationProperty
private final Vectorstore vectorstore = new Vectorstore();
public Boolean getToolCalls() {
return toolCalls;
}
@@ -43,4 +50,24 @@ public class CmsAiProperties {
public void setDefaultPromptTemplate(String defaultPromptTemplate) {
this.defaultPromptTemplate = defaultPromptTemplate;
}
public Vectorstore getVectorstore() {
return vectorstore;
}
public static class Vectorstore {
/**
* 向量库类型选择chroma、pgvector、elasticsearch、milvus
*/
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
}

View File

@@ -3,6 +3,13 @@
spring:
ai:
# 模型选择openai、ollama
model:
chat: ollama
embedding: ${spring.ai.model.chat}
image: ${spring.ai.model.chat}
audio: ${spring.ai.model.chat}
# 在线大模型【请在 pom.xml 中打开 openai 的注释,并注释上其它模型】
openai:
@@ -83,6 +90,9 @@ spring:
# 向量数据库配置
vectorstore:
# 向量库类型chroma、pgvector、elasticsearch、milvus
type: chroma
# Chroma 向量数据库【请在 pom.xml 中打开 chroma 的注释,并注释上其它向量库】
chroma:
client:

View File

@@ -13,7 +13,7 @@
<artifactId>jeesite-web-ai</artifactId>
<packaging>war</packaging>
<description>Web AI 服务,也可为分离端提供接口服务</description>
<description>Web AI 服务</description>
<name>JeeSite Web AI</name>
<url>http://jeesite.com</url>