mirror of
https://gitee.com/270580156/weiyu.git
synced 2025-12-30 10:52:26 +00:00
update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<Document> 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)
|
||||
@@ -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}")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user