Skip to content

Commit 6cb15e4

Browse files
jaeyeonlingilayaperumalg
authored andcommitted
Update azure-openai-chat.adoc
Signed-off-by: jaeyeonling <[email protected]>
1 parent 6be3d0a commit 6cb15e4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,24 +335,26 @@ Next, create an `AzureOpenAiChatModel` instance and use it to generate text resp
335335

336336
[source,java]
337337
----
338-
var openAIClient = new OpenAIClientBuilder()
338+
var openAIClientBuilder = new OpenAIClientBuilder()
339339
.credential(new AzureKeyCredential(System.getenv("AZURE_OPENAI_API_KEY")))
340-
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"))
341-
.buildClient();
340+
.endpoint(System.getenv("AZURE_OPENAI_ENDPOINT"));
342341
343342
var openAIChatOptions = AzureOpenAiChatOptions.builder()
344343
.deploymentName("gpt-4o")
345344
.temperature(0.4)
346345
.maxTokens(200)
347346
.build();
348347
349-
var chatModel = new AzureOpenAiChatModel(this.openAIClient, this.openAIChatOptions);
348+
var chatModel = AzureOpenAiChatModel.builder()
349+
.openAIClientBuilder(openAIClientBuilder)
350+
.defaultOptions(openAIChatOptions)
351+
.build();
350352
351-
ChatResponse response = this.chatModel.call(
353+
ChatResponse response = chatModel.call(
352354
new Prompt("Generate the names of 5 famous pirates."));
353355
354356
// Or with streaming responses
355-
Flux<ChatResponse> response = this.chatModel.stream(
357+
Flux<ChatResponse> streamingResponses = chatModel.stream(
356358
new Prompt("Generate the names of 5 famous pirates."));
357359
358360
----

0 commit comments

Comments
 (0)