Skip to content

Commit cb4f356

Browse files
authored
refactor: fix DeepSeekChatModel initialization to use builder pattern (#4421)
Auto-cherry-pick to 1.0.x Fixes #4421 Signed-off-by: fatebug <1339524041@qq.com>
1 parent b7f231a commit cb4f356

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/deepseek-chat.adoc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,18 @@ Next, create a `DeepSeekChatModel` and use it for text generation:
313313

314314
[source,java]
315315
----
316-
var deepSeekApi = new DeepSeekApi(System.getenv("DEEPSEEK_API_KEY"));
317-
318-
var chatModel = new DeepSeekChatModel(deepSeekApi, DeepSeekChatOptions.builder()
319-
.withModel(DeepSeekApi.ChatModel.DEEPSEEK_CHAT.getValue())
320-
.withTemperature(0.4f)
321-
.withMaxTokens(200)
322-
.build());
323-
316+
DeepSeekApi deepSeekApi = DeepSeekApi.builder()
317+
.apiKey(System.getenv("DEEPSEEK_API_KEY"))
318+
.build();
319+
DeepSeekChatOptions options = DeepSeekChatOptions.builder()
320+
.model(DeepSeekApi.ChatModel.DEEPSEEK_CHAT.getValue())
321+
.temperature(0.4)
322+
.maxTokens(200)
323+
.build();
324+
DeepSeekChatModel chatModel = DeepSeekChatModel.builder()
325+
.deepSeekApi(deepSeekApi)
326+
.defaultOptions(options)
327+
.build();
324328
ChatResponse response = chatModel.call(
325329
new Prompt("Generate the names of 5 famous pirates."));
326330

0 commit comments

Comments
 (0)