Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed Jun 19, 2024
1 parent ade056c commit 026fcb9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](./README.md) | [中文](./README_zh_CN.md)

Aliyun Dashscope Client for Spring AI
Aliyun Dashscope Model for Spring AI

[![build](https://github.com/JavaAIDev/spring-ai-dashscope-client/actions/workflows/build.yaml/badge.svg)](https://github.com/JavaAIDev/spring-ai-dashscope-client/actions/workflows/build.yaml)

Expand All @@ -28,15 +28,15 @@ Add [Maven dependency](https://central.sonatype.com/artifact/io.github.alexcheng
Usage:

```java
var client = DashscopeChatClient.createDefault();
var response = client.call("hello");
var model = DashscopeChatModel.createDefault();
var response = model.call("hello");
```

## Features

* `ChatClient`
* `StreamingChatClient`
* `EmbeddingClient`
* `ChatModel`
* `StreamingChatModel`
* `EmbeddingModel`
* Function calling
* Multimodal input with images and audios

Expand All @@ -53,7 +53,7 @@ Add Spring Boot starter:
</dependency>
```

This will create a `ChatClient` bean and an `EmbeddingClient` bean.
This will create a `ChatModel` bean and an `EmbeddingModel` bean.
Default `ChatOptions` can be configured
with the configuration key `spring.ai.dashscope.chat.options`.
Default `EmbeddingOptions` can be configured with the configuration
Expand Down
14 changes: 7 additions & 7 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[English](./README.md) | [中文](./README_zh_CN.md)

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

[![build](https://github.com/JavaAIDev/spring-ai-dashscope-client/actions/workflows/build.yaml/badge.svg)](https://github.com/JavaAIDev/spring-ai-dashscope-client/actions/workflows/build.yaml)

Expand All @@ -27,15 +27,15 @@
使用:

```java
var client = DashscopeChatClient.createDefault();
var response = client.call("hello");
var model = DashscopeChatModel.createDefault();
var response = model.call("hello");
```

## 功能

* `ChatClient`
* `StreamingChatClient`
* `EmbeddingClient`
* `ChatModel`
* `StreamingChatModel`
* `EmbeddingModel`
* 方法调用
* 多模态输入,图片和音频

Expand All @@ -52,7 +52,7 @@ var response = client.call("hello");
</dependency>
```

会自动创建一个 `ChatClient` 类型的 Bean 和一个 `EmbeddingClient` 类型的
会自动创建一个 `ChatModel` 类型的 Bean 和一个 `EmbeddingModel` 类型的
Bean。默认的 `ChatOptions`
可以通过配置项 `spring.ai.dashscope.chat.options`
来配置。默认的 `EmbeddingOptions`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ class DashscopeChatModelTest {

@Test
void smokeTest() {
var client = DashscopeChatModel.createDefault();
var response = client.call("hello");
var model = DashscopeChatModel.createDefault();
var response = model.call("hello");
assertNotNull(response);
}

@Test
void streamSmokeTest() {
var client = DashscopeChatModel.createDefault();
var response = client.stream("如何做西红柿炖牛腩?");
var model = DashscopeChatModel.createDefault();
var response = model.stream("如何做西红柿炖牛腩?");
response.toIterable().forEach(System.out::println);
}

@Test
void multiModalImageSmokeTest() throws MalformedURLException {
var client = DashscopeChatModel.createDefault();
var model = DashscopeChatModel.createDefault();
var prompt = new Prompt(new UserMessage("这是什么?",
List.of(
new Media(IMAGE_JPEG,
Expand All @@ -45,13 +45,13 @@ void multiModalImageSmokeTest() throws MalformedURLException {
DashscopeChatOptions.builder()
.withModel(DashscopeModelName.QWEN_VL_PLUS)
.build());
var response = client.call(prompt);
var response = model.call(prompt);
System.out.println(response.getResult().getOutput().getContent());
}

@Test
void multiModalImageSmokeTest2() throws MalformedURLException {
var client = DashscopeChatModel.createDefault();
var model = DashscopeChatModel.createDefault();
var prompt = new Prompt(new UserMessage("用图片中的这些食材,做一道菜",
List.of(
new Media(IMAGE_JPEG,
Expand All @@ -61,13 +61,13 @@ void multiModalImageSmokeTest2() throws MalformedURLException {
DashscopeChatOptions.builder()
.withModel(DashscopeModelName.QWEN_VL_PLUS)
.build());
var response = client.call(prompt);
var response = model.call(prompt);
System.out.println(response.getResult().getOutput().getContent());
}

@Test
void multiModalAudioSmokeTest() throws MalformedURLException {
var client = DashscopeChatModel.createDefault();
var model = DashscopeChatModel.createDefault();
var prompt = new Prompt(new UserMessage("这段音频在说什么?",
List.of(
new Media(new MimeType("audio", "wav"),
Expand All @@ -78,7 +78,7 @@ void multiModalAudioSmokeTest() throws MalformedURLException {
.withModel(DashscopeModelName.QWEN_AUDIO_TURBO)
.withMaxTokens(100)
.build());
var response = client.call(prompt);
var response = model.call(prompt);
System.out.println(response.getResult().getOutput().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class DashscopeEmbeddingModelTest {

@Test
void smokeTest() {
var client = new DashscopeEmbeddingModel();
var result = client.embed("hello");
var model = new DashscopeEmbeddingModel();
var result = model.embed("hello");
assertNotNull(result);
assertFalse(result.isEmpty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ String runFunction() {
.withName("add")
.withDescription("add two numbers")
.build());
var client = new DashscopeChatModel(new DashscopeApi(), context);
var response = client.call(new Prompt("add 100 to 200", options));
var model = new DashscopeChatModel(new DashscopeApi(), context);
var response = model.call(new Prompt("add 100 to 200", options));
return response.getResult().getOutput().getContent();
}

Expand Down

0 comments on commit 026fcb9

Please sign in to comment.