From efc2c159b60da5be2ead78972cb207c50c240e1e Mon Sep 17 00:00:00 2001 From: jack ning Date: Fri, 18 Jul 2025 12:02:16 +0800 Subject: [PATCH] update --- deploy/server/config/application.properties | 2 +- .../ai/springai/providers/dashscope/README.md | 105 ------------------ .../SpringAIDashscopeChatConfig.java | 4 +- .../resources/application-open.properties | 2 +- 4 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/README.md diff --git a/deploy/server/config/application.properties b/deploy/server/config/application.properties index 4206c4dd2a..651ea1fa26 100644 --- a/deploy/server/config/application.properties +++ b/deploy/server/config/application.properties @@ -732,7 +732,7 @@ spring.ai.openai.moderation.enabled=false spring.ai.dashscope.base-url=https://dashscope.aliyuncs.com/compatible-mode spring.ai.dashscope.api-key=sk-xxx spring.ai.dashscope.chat.enabled=false -spring.ai.dashscope.chat.options.model=deepseek-r1 +spring.ai.dashscope.chat.options.model=qwen-max spring.ai.dashscope.chat.options.temperature=0.7 spring.ai.dashscope.chat.options.topP=3 spring.ai.dashscope.audio.transcription.enabled=false diff --git a/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/README.md b/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/README.md deleted file mode 100644 index 0c5003141d..0000000000 --- a/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/README.md +++ /dev/null @@ -1,105 +0,0 @@ -# Spring AI Dashscope Embedding 配置 - -## 概述 - -本模块提供了阿里云 Dashscope 的 Spring AI Embedding 集成配置,支持文本向量化功能。 - -## 配置说明 - -### 1. 启用配置 - -在 `application.properties` 或 `application.yml` 中添加以下配置: - -```properties -# 启用 Dashscope Embedding -spring.ai.dashscope.embedding.enabled=true - -# Dashscope API 配置 -spring.ai.dashscope.base-url=https://dashscope.aliyuncs.com/compatible-mode -spring.ai.dashscope.api-key=your-api-key-here - -# Embedding 模型配置 -spring.ai.dashscope.embedding.options.model=text-embedding-v1 -``` - -### 2. 设置为主 Embedding 模型 - -要将 Dashscope 设置为主 Embedding 模型,添加以下配置: - -```properties -spring.ai.model.embedding=dashscope -``` - -## 支持的模型 - -- `text-embedding-v1`: 阿里云 Dashscope 文本嵌入模型 - -## 使用方法 - -### 1. 自动注入 EmbeddingModel - -```java -@Autowired -@Qualifier("bytedeskDashscopeEmbeddingModel") -private EmbeddingModel dashscopeEmbeddingModel; - -// 使用示例 -float[] embedding = dashscopeEmbeddingModel.embed("Hello, world!"); -``` - -### 2. 在 RAG 中使用 - -当设置 `spring.ai.model.embedding=dashscope` 时,系统会自动使用 Dashscope 作为主 Embedding 模型: - -```java -@Autowired -private EmbeddingModel embeddingModel; // 会自动注入 Dashscope 模型 - -@Autowired -private VectorStore vectorStore; - -// 文档向量化 -vectorStore.add(documents); - -// 相似性搜索 -List similarDocs = vectorStore.similaritySearch("查询文本"); -``` - -## 配置类说明 - -### SpringAIDashscopeEmbeddingConfig - -主要的配置类,负责创建以下 Bean: - -- `bytedeskDashscopeEmbeddingApi`: OpenAiApi 实例 -- `bytedeskDashscopeEmbeddingOptions`: Embedding 选项配置 -- `bytedeskDashscopeEmbeddingModel`: EmbeddingModel 实例 - -### 配置属性 - -| 属性 | 默认值 | 说明 | -|------|--------|------| -| `spring.ai.dashscope.embedding.enabled` | `false` | 是否启用 Dashscope Embedding | -| `spring.ai.dashscope.base-url` | `https://dashscope.aliyuncs.com/compatible-mode` | API 基础 URL | -| `spring.ai.dashscope.api-key` | `sk-xxx` | API 密钥 | -| `spring.ai.dashscope.embedding.options.model` | `text-embedding-v1` | 使用的模型名称 | - -## 测试 - -运行测试以验证配置: - -```bash -mvn test -Dtest=SpringAIDashscopeEmbeddingConfigTest -``` - -## 注意事项 - -1. 需要有效的阿里云 Dashscope API 密钥 -2. 确保网络能够访问 `dashscope.aliyuncs.com` -3. 模型 `text-embedding-v1` 是阿里云 Dashscope 兼容 OpenAI 格式的嵌入模型 - -## 相关链接 - -- [阿里云百炼大模型](https://bailian.console.aliyun.com/) -- [Spring AI 文档](https://docs.spring.io/spring-ai/reference/) -- [Spring AI Alibaba](https://github.com/alibaba/spring-ai-alibaba) \ No newline at end of file diff --git a/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/SpringAIDashscopeChatConfig.java b/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/SpringAIDashscopeChatConfig.java index d465ae49d8..16b238485b 100644 --- a/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/SpringAIDashscopeChatConfig.java +++ b/modules/ai/src/main/java/com/bytedesk/ai/springai/providers/dashscope/SpringAIDashscopeChatConfig.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2025-02-17 11:17:28 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-07-18 11:44:44 + * @LastEditTime: 2025-07-18 12:00:42 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -40,7 +40,7 @@ public class SpringAIDashscopeChatConfig { @Value("${spring.ai.dashscope.api-key:sk-xxx}") private String apiKey; - @Value("${spring.ai.dashscope.chat.options.model:deepseek-r1}") + @Value("${spring.ai.dashscope.chat.options.model:qwen-max}") private String model; @Value("${spring.ai.dashscope.chat.options.temperature:0.7}") diff --git a/starter/src/main/resources/application-open.properties b/starter/src/main/resources/application-open.properties index 788631181f..d1c42e3188 100644 --- a/starter/src/main/resources/application-open.properties +++ b/starter/src/main/resources/application-open.properties @@ -712,7 +712,7 @@ spring.ai.dashscope.enabled=false spring.ai.dashscope.base-url=https://dashscope.aliyuncs.com/compatible-mode spring.ai.dashscope.api-key=sk-xxx spring.ai.dashscope.chat.enabled=false -spring.ai.dashscope.chat.options.model=deepseek-r1 +spring.ai.dashscope.chat.options.model=qwen-max spring.ai.dashscope.chat.options.temperature=0.7 spring.ai.dashscope.chat.options.topP=3 spring.ai.dashscope.audio.transcription.enabled=false