Skip to content

Commit 08aa4c6

Browse files
committed
2 parents ba31318 + e037c33 commit 08aa4c6

File tree

13 files changed

+252
-146
lines changed

13 files changed

+252
-146
lines changed

spring-ai-alibaba-chat-example/deepseek-chat/deepseek-chat-client/src/main/resources/application.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ spring:
77

88
ai:
99
openai:
10-
api-key:
11-
${AI_OPENAI_API_KEY}
12-
base-url: ${AI_OPENAI_BASE_URL}
10+
api-key: ${AI_DEEPSEEK_API_KEY}
11+
base-url: https://api.deepseek.com
1312
chat:
1413
options:
15-
model: ${AI_OPENAI_CHAT_MODEL}
14+
model: deepseek-chat
1615
embedding:
1716
enabled: false

spring-ai-alibaba-chat-example/deepseek-chat/deepseek-chat-model/src/main/resources/application.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ spring:
77

88
ai:
99
openai:
10-
api-key: ${AI_OPENAI_API_KEY}
11-
base-url: ${AI_OPENAI_BASE_URL}
10+
api-key: ${AI_DEEPSEEK_API_KEY}
11+
base-url: https://api.deepseek.com
1212
chat:
1313
options:
14-
model: ${AI_OPENAI_CHAT_MODEL}
14+
model: deepseek-chat
1515
embedding:
1616
enabled: false

spring-ai-alibaba-chat-example/deepseek-chat/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<description>Spring AI Alibaba DeepSeek Chat Example</description>
3535
<name>Spring AI Alibaba DeepSeek Chat Examples</name>
3636

37+
<modules>
38+
<module>deepseek-chat-model</module>
39+
<module>deepseek-chat-client</module>
40+
</modules>
41+
3742
<dependencies>
3843
<dependency>
3944
<groupId>org.springframework.boot</groupId>
@@ -46,11 +51,6 @@
4651
</dependency>
4752
</dependencies>
4853

49-
<!-- <modules>-->
50-
<!-- <module>deepseek-chat-model</module>-->
51-
<!-- <module>deepseek-chat-client</module>-->
52-
<!-- </modules>-->
53-
5454
<build>
5555
<plugins>
5656
<plugin>

spring-ai-alibaba-chat-example/moonshot-chat/moonshot-chat-client/src/main/java/com/alibaba/cloud/ai/example/chat/moonshot/controller/MoonshotClientController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public MoonshotClientController(ChatClient.Builder chatClientBuilder) {
4949
// 设置Options
5050
.defaultOptions(
5151
MoonshotChatOptions.builder()
52-
.withTopP(0.8)
53-
.withTemperature(0.8)
52+
.topP(0.8)
53+
.temperature(0.8)
5454
.build()
5555
)
5656
.build();

spring-ai-alibaba-chat-example/moonshot-chat/moonshot-chat-model/src/main/java/com/alibaba/cloud/ai/example/chat/moonshot/controller/MoonshotModelController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public Flux<String> streamChat(HttpServletResponse response) {
7878
@GetMapping("/custom/chat")
7979
public String customChat() {
8080
MoonshotChatOptions moonshotChatOptions = MoonshotChatOptions.builder()
81-
.withModel("moonshot-v1-32k")
82-
.withTopP(0.8)
83-
.withTemperature(0.8)
81+
.model("moonshot-v1-32k")
82+
.topP(0.8)
83+
.temperature(0.8)
8484
.build();
8585

8686
return moonshotChatModel.call(new Prompt(DEFAULT_PROMPT, moonshotChatOptions)).getResult().getOutput().getContent();

spring-ai-alibaba-chat-example/ollama-chat/ollama-chat-model/src/main/java/com/alibaba/cloud/ai/example/chat/ollama/controller/OllamaChatModelController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public Flux<String> streamChat(HttpServletResponse response) {
7979
public String customChat() {
8080

8181
OllamaOptions customOptions = OllamaOptions.builder()
82-
.withTopP(0.7)
83-
.withModel("llama3")
84-
.withTemperature(0.8)
82+
.topP(0.7)
83+
.model("llama3")
84+
.temperature(0.8)
8585
.build();
8686

8787
return ollamaChatModel.call(new Prompt(DEFAULT_PROMPT, customOptions)).getResult().getOutput().getContent();

spring-ai-alibaba-chat-example/openai-chat/openai-chat-client/src/main/java/com/alibaba/cloud/ai/example/chat/openai/controller/OpenAiClientController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public OpenAiClientController(ChatModel chatModel) {
5151
// 设置 ChatClient 中 ChatModel 的 Options 参数
5252
.defaultOptions(
5353
OpenAiChatOptions.builder()
54-
.withTopP(0.7)
54+
.topP(0.7)
5555
.build()
5656
)
5757
.build();

spring-ai-alibaba-chat-example/openai-chat/openai-chat-model/src/main/java/com/alibaba/cloud/ai/example/chat/openai/controller/OpenAiChatModelController.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.ai.chat.model.ChatResponse;
2323
import org.springframework.ai.chat.prompt.Prompt;
2424
import org.springframework.ai.openai.OpenAiChatOptions;
25-
import org.springframework.ai.openai.api.OpenAiApi;
2625
import org.springframework.ai.openai.api.ResponseFormat;
2726
import org.springframework.web.bind.annotation.GetMapping;
2827
import org.springframework.web.bind.annotation.RequestMapping;
@@ -81,10 +80,10 @@ public Flux<String> streamChat(HttpServletResponse response) {
8180
public String customChat() {
8281

8382
OpenAiChatOptions customOptions = OpenAiChatOptions.builder()
84-
.withTopP(0.7)
85-
.withModel("gpt-4o")
86-
.withMaxTokens(1000)
87-
.withTemperature(0.8)
83+
.topP(0.7)
84+
.model("gpt-4o")
85+
.maxTokens(1000)
86+
.temperature(0.8)
8887
.build();
8988

9089
return openAiChatModel.call(new Prompt(DEFAULT_PROMPT, customOptions)).getResult().getOutput().getContent();
@@ -122,11 +121,11 @@ public String jsonChat() {
122121
""";
123122

124123
OpenAiChatOptions customOptions = OpenAiChatOptions.builder()
125-
.withTopP(0.7)
126-
.withModel("gpt-4o")
127-
.withTemperature(0.4)
128-
.withMaxTokens(4096)
129-
.withResponseFormat(new ResponseFormat(ResponseFormat.Type.JSON_SCHEMA, jsonSchema))
124+
.topP(0.7)
125+
.model("gpt-4o")
126+
.temperature(0.4)
127+
.maxTokens(4096)
128+
.responseFormat(new ResponseFormat(ResponseFormat.Type.JSON_SCHEMA, jsonSchema))
130129
.build();
131130

132131
return openAiChatModel.call(new Prompt(JSON_OUTPUT_PROMPT, customOptions)).getResult().getOutput().getContent();

spring-ai-alibaba-chat-example/zhipuai-chat/zhipuai-chat-client/src/main/java/com/alibaba/cloud/ai/example/chat/zhipuai/controller/ZhiPuAiClientController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ZhiPuAiClientController(ChatModel chatModel) {
4848
// 设置 ChatClient 中 ChatModel 的 Options 参数
4949
.defaultOptions(
5050
ZhiPuAiChatOptions.builder()
51-
.withTopP(0.7)
51+
.topP(0.7)
5252
.build()
5353
)
5454
.build();

spring-ai-alibaba-chat-example/zhipuai-chat/zhipuai-chat-model/src/main/java/com/alibaba/cloud/ai/example/chat/zhipuai/controller/ZhiPuAiChatModelController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public Flux<String> streamChat(HttpServletResponse response) {
8080
public String customChat() {
8181

8282
ZhiPuAiChatOptions customOptions = ZhiPuAiChatOptions.builder()
83-
.withTopP(0.7)
84-
.withModel("glm-4-flash")
85-
.withMaxTokens(1000)
86-
.withTemperature(0.8)
83+
.topP(0.7)
84+
.model("glm-4-flash")
85+
.maxTokens(1000)
86+
.temperature(0.8)
8787
.build();
8888

8989
return zhipuAiChatModel.call(new Prompt(DEFAULT_PROMPT, customOptions)).getResult().getOutput().getContent();

0 commit comments

Comments
 (0)