Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 2.08 KB

README_zh_CN.md

File metadata and controls

78 lines (56 loc) · 2.08 KB

Spring AI 阿里云模型服务灵积(Dashscope)模型

English | 中文

阿里云模型服务灵积(Dashscope)Spring AI 集成模型

build

Maven Central Version

版本

客户端/模型版本 Spring AI 版本
1.1.x 0.8.1
>= 1.3.x 1.0.0

需要阿里云模型服务灵积的 API Key,设置为环境变量 DASHSCOPE_API_KEY

快速上手

添加 Maven 依赖

<dependency>
  <groupId>io.github.alexcheng1982</groupId>
  <artifactId>spring-ai-dashscope-client</artifactId>
  <version>VERSION</version>
</dependency>

使用:

var model = DashscopeChatModel.createDefault();
var response = model.call("hello");

功能

  • ChatModel
  • StreamingChatModel
  • EmbeddingModel
  • 方法调用
  • 多模态输入,图片和音频

Spring Boot 集成

添加 Spring Boot Starter 的依赖:

<dependency>
  <groupId>io.github.alexcheng1982</groupId>
  <artifactId>spring-ai-dashscope-spring-boot-starter</artifactId>
  <version>VERSION</version>
</dependency>

会自动创建一个 ChatModel 类型的 Bean 和一个 EmbeddingModel 类型的 Bean。默认的 ChatOptions 可以通过配置项 spring.ai.dashscope.chat.options 来配置。默认的 EmbeddingOptions 可以通过配置项 spring.ai.dashscope.embedding.options 来配置。

spring:
  ai:
    dashscope:
      chat:
        options:
          model: qwen-plus
          temperature: 0.2
      embedding:
        options:
          model: text-embedding-v2

可以参考代码示例