Skip to content

Commit 450fb39

Browse files
authored
Merge pull request #68 from wstever/main
fix:SpringAI M5 modify the ChatOptions params
2 parents 579dbfb + 706bec6 commit 450fb39

File tree

8 files changed

+25
-26
lines changed

8 files changed

+25
-26
lines changed

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();

spring-ai-alibaba-multi-model-example/ark-multi-model/src/main/java/com/alibaba/cloud/ai/example/controller/MultiModelController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/**
4343
* ark Multi-Model REST Controller
4444
* 提供聊天、图片生成、文本向量等多个模型能力的API接口
45-
*
45+
*
4646
* @author brian xiadong
4747
*/
4848
@RestController
@@ -78,7 +78,7 @@ public MultiModelController(ChatModel chatModel) {
7878
// 设置 ChatClient 中 ChatModel 的 Options 参数
7979
.defaultOptions(
8080
OpenAiChatOptions.builder()
81-
.withTopP(0.7)
81+
.topP(0.7)
8282
.build()
8383
)
8484
.build();

0 commit comments

Comments
 (0)